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

Consider deprecating and/or removing #stub! and #unstub! at some point #122

Closed
myronmarston opened this issue Mar 28, 2012 · 7 comments
Closed

Comments

@myronmarston
Copy link
Member

#stub! and #unstub! are just aliases for #stub and #unstub, respectively. They don't seem to serve a lot of purpose at this point. I'm not really sure what the original reason to have both was.

Given that they are methods added to every object in the system, and it behooves us to add as few methods to every object in the system as possible, I think we should consider deprecating and/or removing #stub! and #unstub!.

Thoughts?

@dchelimsky
Copy link
Contributor

Agree 100% but this will be a wide-reaching change, so we need to treat it with care. Here's what I propose:

  1. add a means for users to pipe RSpec's deprecation warnings to a file
  2. deprecate this and start deprecating everything else we want to remove for 3.0

@tovodeverett
Copy link

Please consider retaining #unstub! - I found a use for it!

The latest version of shoulda-matchers requires bourne, and bourne in turn requires mocha. I prefer the RSpec stubbing functionality, and since Mocha uses #stubs instead of #stub, stubbing can coexist. But Mocha uses #unstub just like RSpec does, so when Mocha loads it knocks out the RSpec #unstub.

I do a global stub for some core functionality that would otherwise slow down the tests, but in one place in my suite I do actually test that functionality and so I use a before(:each) block to unstub that call. It took me a while to figure out what was going on when 'shoulda-matchers' updated recently and I had to troubleshoot, but in the end having #unstub! around was very handy.

@dolzenko
Copy link

Had just the same issue as @tovodeverett described with test suite breaking after bundle update, almost suconsciously tried replacing unstub with unstub! and it worked, then found this :) But it looks like it should be fixed by shoulda-matchers then?

@alindeman
Copy link
Contributor

The latest version of shoulda-matchers requires bourne, and bourne in turn requires mocha. I prefer the RSpec stubbing functionality, and since Mocha uses #stubs instead of #stub, stubbing can coexist. But Mocha uses #unstub just like RSpec does, so when Mocha loads it knocks out the RSpec #unstub.

Does shoulda-matchers actually need mocha at runtime, or is it unintentional leakage?

@JonRowe
Copy link
Member

JonRowe commented Mar 14, 2013

I'm a fan of deprecating stub! and unstub!, they don't mean anything over the normal methods, it's also unexpected because of the significance we normally place on ! methods...

I also feel that conflict with a 3rd party library (which has always existed) should be resolved on that library, not on the main library...

@myronmarston
Copy link
Member Author

Let's go ahead and deprecate the now, with the plan to remove them in 3.0.

@myronmarston
Copy link
Member Author

Addressed by @JonRowe in #242.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants