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
creating a double in before :all #202
Comments
I noticed this too in a non-rails project. |
Test doubles, mocks, stubs all get rolled back after each example, so before(:all) would not work even if it were made available. I'll leave this open while I figure out where/how to best document this fact. |
I have this problem as well. https://github.com/agmcleod/Copy-Process/blob/experimental/spec/copyprocess/processor_spec.rb Line 226. However, if i take out the i method call, following it, it works fine. line 230 is for the original poster's workaround. |
Sorry, that's the it method call. Comment that out and the block passing to it, tests pass, no failures. |
It would be nice if RSpec could raise a developer-friendly error message instead of just |
@h3h - my only concern w/ doing that is that ppl who use non-rspec frameworks would not get the same friendly messages. Seems like we'd be opening a can o' worms. |
I don't know enough to say whether it'd be a can of worms to add this, but I agree that an error such as "You cannot create a double in a before :all block" error would be much more helpful, as if you expect a double to work and get no method, you're more likely to think that you've spelled something wrong or missed a require than that you're just not able to make a double in that context. |
+1 There should be a better error message. |
I just hit this problem... |
This has been resolved in RSpec 3 -- if you upgrade you'll get it. |
Ah, thanks 👍 |
Creating a double in a before :all block triggers this error:
undefined method `double' for #RSpec::Core::ExampleGroup::Nested_1::Nested_1:0x00000001996b90
If I remove the :all, (or change to :each), the block evaluates without incident.
Rspec 2.0.1, Rails 3.
The text was updated successfully, but these errors were encountered: