Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Don't error out when config.mock_with or expect_with is re-specifying the current config #490
See this comment.
We should change the code that raises an error so that it does nothing if these config options are simply re-specifying the current configuration (whether the default or not), since they are essentially a no-op in this case.
Looking forward to this fix. The other annoying thing is it went from a warning message about deprecated behavior being removed in RSpec 3.0 to something that just flat out errors in RSpec 2.7, breaking both with the contract of RSpec minor releases and the deprecation notice.
The plan was to follow the deprecation/removal path until we got complaints about it. rspec/rspec-rails#371 contains a good portion of the discussion that went into changing the warning for all config-after-example-group-definition to an error for specific configs-after-example-group-definition. My comment there goes into detail about the specific ruby 1.9 bug we have been trying to work around with this.
For now, just remove
Got any ideas for how we could have dealt with the ruby 1.9 bug better?
I actually mock with mocha, so removing the line isn't much of an option. I went through and changed all my require statements to be the relative
So, I can now run rake with RSpec 2.7 fine, but I've lost the ability to run any spec in isolation. I'm not wild about that prospect either.
I'm still running REE because 1.9.2 has been an unstable, buggy release for me. So unfortunately I can't weigh in more on that matter. Sounds like being stuck between a rock and a hard place. I guess having a wiki page or a better error message would have helped. For the life of me I couldn't figure out how I already had example groups defined. I didn't realize the configure stuff was non-reentrant. But if it can recall the example group state between calls, it should probably be able to remember its configuration between calls too, as you suggest above.
If you have any ideas for making it more intuitive, please feel free to update the wording of the error and submit a pull request :).
I think you just need to re-order have you require and configure things. The important thing is that to prevent mysterious, confusing
require 'rspec' RSpec.configure do |c| c.mock_with :mocha end
require 'fast_spec_helper' # load rails or whatever to get your full app environment booted RSpec.configure do |c| # other spec configuration end
in a fast isolated spec:
require 'fast_spec_helper' describe MyClass do end
in a non-isolated spec:
require 'spec_helper' describe MyRailsController do end
The idea here is that we need to configure
Let me know if that doesn't work for you.
And thanks for your patience on this manner! I know the changes here have caused pain for some users, and I really wish there was a better way...
referenced this issue
Nov 3, 2011
@kevinmccaughey -- Sorry to hear that. Can you post a reproducible example? I'll take a look at it.
BTW, I posted a blog post describing the background to this issue:
...so if you want to understand more about what's going on, check that out.
I am only a beginner so I was maybe confused about the functionality - I
Thanks for taking the time to check on this - I will keep learning and
All the best,
On 27/07/2012 19:22, Myron Marston wrote:
I will link to the listing in the (free) online book (current version). The line is 2/3 of the way down: config.mock_with :rspec
Now this seemed sensible to me, so I was really confused when the only way to get the listing to work was to remove that line (config.mock_with :rspec)