-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
undefined method `env' for nil:NilClass in RSpec 2.10 #534
Comments
Thanks for reporting this here. I do have a guess as to the source of the problem, but can't really prove it w/o a minimal app to repro the bug. Thanks in advance for providing that. The change that probably caused it is 47907b3, which reverses the order of any setup methods. That was done in a general way to address a specific problem, so if that is the source of the problem we'll need to prepend the specific setup method from Rails. I don't love that idea because it means if Rails changes the name of that setup method RSpec will experience the regression, but it might be a reasonable tradeoff. Let me know when you have a sample app I can experiment with. Thanks! |
@josevalim FYI - pls read comments above and feel free to add commentary here. |
@dchelimsky maybe we can prepend just rails helpers? I think the issue is that Devise test helpers are also using setup and therefore being prepended by mistake. I haven't taken a look at the source code but, if Rails has two callbacks (A and B) where B depends on A being executed first, wouldn't that be broken in rspec-rails if you prepend everything by default (the order would be reversed)? |
@josevalim that's what I was suggesting in my previous comment. Specifically prepending only the |
FYI - I'm going to go ahead and make that change and get a fix release out, but probably not until tomorrow. |
@dchelimsky instead of listing the method names, can't you list the class/module/self? It is more unlikely that the class/module name will change instead of the method name. |
@josevalim self is going to be a subclass of |
Yeah, that's what I meant. :( So no other option then. |
It's probably the right thing to do, but I'll be sad if a Rails release breaks it. Hopefully travis-ci will help me know if/when that happens in advance. |
@sekrett can you verify this fixes your problem? Once you do I'm going to release this over the weekend. |
Yes, on master it works now. Thank you. |
Just released rspec-rails-2.10.1 with this fix. |
Ditto for me. Thanks! |
Just got rspec-rails-2.10.0 with the same error. If I edit my Gemfile.lock to rspec-rails-2.10.1 and bundle update, will that get rid of the error? |
You'd better issue the command |
Thanks. I did that but it did not fix my problem. Is it okay if I post the backtrace? It says something about 'block on autorun' every time I run Guard |
@raybesiga you don't need to ask to post a backtrace. Please do. |
Here it is: C:\Sites\tasks>guard |
I just encountered the same issue. Had to change my before callback to a before(:each) |
I have the same problem. but when I downgrade to 2.9.0 make it work. |
@raybesiga use @smasry what callback? @chucai the bug is in 2.10.0, but fixed in 2.10.1. Did you upgrade to 2.10.1 or 2.11.0? |
Thanks! @dchelimsky |
@dchelimsky Thanks! |
I am using Rails 3.2.6 and RSpec 2.11.0 and I have the same issue. |
I downgraded to RSpec 2.9.0 and still getting "undefined method `env' for nil:NilClass". Any ideas for a quick workaround? Or is it possible that it is not related to this issue? Right now I have to disable SSL for the UI Tests to make the tests work. Would be cool if I don't have to work around RSpec. I appreciate any kind of feedback. Many thanks. |
@reiz doubt that's the same issue. This particular issue is unique to rspec-rails-2.10.0. It was not present for 2.9 or 2.10.1. Please submit a separate issue with the relevant spec, code, and failure message. |
@dchelimsky OK. Will do. Many Thanks. |
Future Googlers: It wasn't as obviously a devise compatibility issue, but I saw devise in the --backtrace and after reading through this issue I upgraded both gems and the error hasn't come up since! Note: The error was sporadic and usually cropped up more when running a full feature rather than a single scenario. The now-working gem combination is rspec-rails 2.14.0 and devise 3.0.0. |
### 2.10.1 / 2012-05-03 [full changelog](http://github.com/rspec/rspec-rails/compare/v2.10.0...v2.10.1) Bug fixes * fix regression introduced in 2.10.0 that broke integration with Devise (rspec/rspec-rails#534) ### 2.10.0 / 2012-05-03 [full changelog](http://github.com/rspec/rspec-rails/compare/v2.9.0...v2.10.0) Bug fixes * `render_views` called in a spec can now override the config setting. (martinsvalin) * Fix `render_views` for anonymous controllers on 1.8.7. (hudge, mudge) * Eliminate use of deprecated `process_view_paths` * Fix false negatives when using `route_to` matcher with `should_not` * `controller` is no longer nil in `config.before` hooks * Change `request.path_parameters` keys to symbols to match real Rails environment (Nathan Broadbent) * Silence deprecation warnings in pre-2.9 generated view specs (Jonathan del Strother)
### 2.10.1 / 2012-05-03 [full changelog](http://github.com/rspec/rspec-rails/compare/v2.10.0...v2.10.1) Bug fixes * fix regression introduced in 2.10.0 that broke integration with Devise (rspec/rspec-rails#534) ### 2.10.0 / 2012-05-03 [full changelog](http://github.com/rspec/rspec-rails/compare/v2.9.0...v2.10.0) Bug fixes * `render_views` called in a spec can now override the config setting. (martinsvalin) * Fix `render_views` for anonymous controllers on 1.8.7. (hudge, mudge) * Eliminate use of deprecated `process_view_paths` * Fix false negatives when using `route_to` matcher with `should_not` * `controller` is no longer nil in `config.before` hooks * Change `request.path_parameters` keys to symbols to match real Rails environment (Nathan Broadbent) * Silence deprecation warnings in pre-2.9 generated view specs (Jonathan del Strother)
Hello!
After upgrading to 2.10 in my Rails 3.2 application I get lots of errors:
Probably it is related to Devise, since this error I see only for controllers. It never happened before. I can try to write a minimal application to reproduce the bug if needed.
For now I downgraded to 2.9 to make it work.
The text was updated successfully, but these errors were encountered: