Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stub.resetBehavior() missing in documentation #267

Closed
ikokostya opened this issue Apr 9, 2013 · 8 comments
Closed

stub.resetBehavior() missing in documentation #267

ikokostya opened this issue Apr 9, 2013 · 8 comments

Comments

@ikokostya
Copy link

sinon 1.6.0

Method stub.resetBehavior() looks like public but it missing in documentation.
What difference between stub.yields() and stub.thenYields()?

@mantoni
Copy link
Member

mantoni commented Apr 10, 2013

There is still work being done regarding resetBehavior (see #244 ). I'm not sure whether it should be documented already.

The same goes for thenYields. The idea is to yield on the first invokation and thenYield on another invokation. This might change again in favor of onCall(n).yields(...).

@ikokostya
Copy link
Author

@mantoni How can I override previous yields() in sinon 1.6.0?

@mantoni
Copy link
Member

mantoni commented Apr 11, 2013

Could you send a more detailed description of what you are trying to do to the mailing list?

@faridnsh
Copy link
Contributor

faridnsh commented Jul 6, 2013

@mantoni The problem of resetBehavior is inconsistency when withArgs is used?

@mantoni
Copy link
Member

mantoni commented Jul 6, 2013

Is it? To be honest, I don't really know. Maybe it could be added to the documentation now, but I'm unsure whether it should really become an "official" part of the API. The ideas developed in the mentioned issue might lead to the function being obsolete - if we ever find the time to finally work on it.
@cjohansen What is your opinion on this?

@cjohansen
Copy link
Contributor

I don't think it should be documented as it won't be needed in the future.

@dotchev
Copy link
Contributor

dotchev commented Aug 13, 2015

I still find resetBehavior useful and worth documenting.

Consider this code

var stub = sinon.stub();
stub.withArgs(1).returns('Bye');

How would you reset this stub to always return 'Hello' for example.
Just doing stub.returns('Hello') does not work.
But this does work

var stub = sinon.stub();
stub.withArgs(1).returns('Bye');
stub.resetBehavior();
stub.returns('Hello');
// stub(1) now returns 'Hello', i.e. old stubbings are reset

Generally it makes a lot of sense to be able to reset all behavior-related changes on a stub.
It would be very useful to clean/reset the stub at the end of each test case.

@mroderick
Copy link
Member

Please don't revive issues that have been closed for years.

We are trying to keep the GitHub issues list tidy and focused on bugs and feature discussions. If you have usage questions, please post them to the Sinon.JS mailinglist, so the bigger community can help answer your questions.

If you believe that you've found a bug in Sinon.JS, please open a brand new ticket and follow the guidelines for reporting an issue.

@sinonjs sinonjs locked and limited conversation to collaborators Aug 17, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants