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

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

Comments

Projects
None yet
6 participants
Owner

myronmarston commented Mar 28, 2012

#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?

Owner

dchelimsky commented Mar 28, 2012

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

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.

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?

Contributor

alindeman commented Dec 17, 2012

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?

Owner

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...

Owner

myronmarston commented Mar 14, 2013

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

Owner

myronmarston commented Mar 16, 2013

Addressed by @JonRowe in #242.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment