-
Notifications
You must be signed in to change notification settings - Fork 202
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
Fix for issue #109. Helpers now available to request specs. #140
Conversation
This fixed issues I was having loading helpers into request specs 👍 +1 |
@timcharper could you merge this please? |
I'm concerned about this patch. I need to get the integration tests working again so I can validate the change. The code that is deleted there was written specifically to address another issue. |
It kills any methods I have in |
+1 for this patch. When doing: bundle exec rspec --drb spec ApplicationHelper methods were not being loaded in controller specs that called "render_views." Now apps/helpers/application_helper.rb methods are available.... (opposite effect of parndt's comment). FYI: |
I need this right now. Does anyone have a workaround? |
The patch introduces other bugs that are tested with the integration tests. I can't reproduce this in isolation. If you want Spork to change, you'll have to prove it's not interaction with some other gem, or distill the interaction down. I'm very sorry, but the complex nature of this problem due to the wide array of gems out there that may hook into the application loader process inclines me to take a very conservative approach. While this patch may make it better for you in this case, it makes things worse for others in known, tested cases. |
That's understandable. Can someone point me to a workaround though? Currently when I try to write a request spec, it goes to render the view and this fails because the view calls helper methods and they aren't found. If there is some code I can write to make this succeed in my test, I don't care. I just need to be able to test my requests. |
Thanks, this worked for me. @eavonius: you can override the method with the original code to workaround this. The code is in the actionpack gem (this is from version 3.2.3). Here I've compressed it to one line: require 'spork'
# Workaround for issue #109 until pull-req #140 gets merged
AbstractController::Helpers::ClassMethods.module_eval do def helper(*args, &block); modules_for_helpers(args).each {|mod| add_template_helper(mod)}; _helpers.module_eval(&block) if block_given?; end end
Spork.prefork do
...
end
Spork.each_run do
...
end |
Thanks ... worked for me. |
+1 thanks @kasperbn for the workaround. I was getting one random failing test when using spork. It would only fail on the test where devise was redirecting to the log-in screen (even though the helper was still being referenced in all the other tests)... |
@kasperbn - Hmm... when using your workaround rspec seems to give the following error if I try to run my specs without using spork:
|
Wrapping the workaround in AbstractController::Helpers::ClassMethods.module_eval do def helper(*args, &block); modules_for_helpers(args).each {|mod| add_template_helper(mod)}; _helpers.module_eval(&block) if block_given?; end end if Spork.using_spork? |
Thanks, this works for me (Rails 3.2.8 / cuke 1.2.1) |
was trying the workaround provided by @kasperbn but somehow spork doesn't seem to reload my helper. Using a helper in |
Closing old pull requests. Please send new ones if this is still an issue. |
I'm not sure if this breaks something else, all I know is that it fixes the issue for me.