Comments (7)
I think I've only ever had one other request for this feature and even that was a long time ago. I just had a quick look at the code and unfortunately it's not as easy to add as I'd like, but I might have go at refactoring the code to make it easier. I'd be interested to know why you need to do it...? Thanks, James.
from mocha.
We have a set of rspec tests an one of them stubs methods on Time, to test out how pages look on different days. Then some other test comes along an uses Time to parse a date and the parsing is always wrong.
from mocha.
Methods should be un-stubbed automatically at the end of a test, so you shouldn't need to manually un-stub. It sounds like there might be a problem with the integration between Mocha and Rspec. Would you be able to put together a simplified test which exhibits the problem?
from mocha.
I have to unstub occassionally in my codebase for a couple of fairly complicated tests
This is the implementation I use
def unstub(object, method)
Mocha::Mockery.instance.stubba.stubba_methods.delete_if do |meth|
meth.stubbee == object && meth.method == method.to_s && true.tap { meth.unstub }
end
end
when unstubbing an "any_instance" stub, I pass in the class
from mocha.
I've just added an unstub method. It would be great if you could try it out and let me know what you think. Please close this issue if you're happy. Thanks, James.
from mocha.
I've just release a new version of Mocha including this change. I'm marking this issue as closed.
from mocha.
oh sorry I didnt see this. Let me try it out :)
from mocha.
Related Issues (20)
- Check Array#flatten works for mock object(s) in Ruby v2.0-v2.2
- Consider improving confusing behaviour for protected & private methods with Mock#responds_like etc
- Consider adding a configuration option to hide satisfied expectations in output
- Mocking a call with empty keyword arguments fails its parameter validation HOT 9
- BasicObjects do not have mocha ObjectMethods HOT 6
- rake test fails with ruby 3.2.0preview3 HOT 5
- Possible regression in JRuby v9.4.0.0 relating to keyword arguments HOT 5
- strict_keyword_argument_matching warning when ruby turns keyword arguments into a positional hash HOT 7
- Expectations with String keys misidentified as keyword arguments HOT 4
- Consider expanding ParameterMatchers#optionally to allow optional keywords arguments
- Consider providing type information via *.rbs and/or *.rbi files HOT 1
- Consider running OpenSSF Scorecard against repo
- Consider using git-cliff to generate changelog
- `with(...) { ... }` should match both given args and block, or reject both HOT 3
- Consider adding ALTERNATIVES.md
- Consider setting changelog_uri in gemspec
- Unpin yard gem when ArgumentException is resolved HOT 1
- Add sitemap to docs site to reduce crawl errors
- Upgraded from 1.0 to 2.0. HOT 7
- Config option for blocking mocks/stubs on specific methods or classes HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mocha.