With rails 3.0.3, rspec/rspec-rails 2.2.0.
It seems that ApplicationHelper is not loaded in helper specs.
Consider the following ApplicationHelper
and a helper method which calls another helper method defined in the ApplicationHelper
Now this test
describe TestingHelper do
describe "with loading ApplicationHelper" do
it "should see methods from ApplicationHelper" do
helper.generic_helper_caller.should == "works"
will fail like so
1) TestingHelper with loading ApplicationHelper should see methods from ApplicationHelper
Failure/Error: helper.generic_helper_caller.should == "works"
undefined local variable or method `test_helper_method' for #<ActionView::Base:0x103506898>
# ./app/helpers/testing_helper.rb:4:in `generic_helper_caller'
Had a bug in the test, and the wrong failure at first, but now they are right and the problem still persists.
For now you can do this:
Seems like that would be a reasonable default. On the flip-side, there is no unextend, so anybody who does not want ApplicationHelper included would be pretty well screwed. Question is whether that's even valid, since Rails will include ApplicationHelper for you anyway.
Well. I think that Rails 3 has gone all upside down with helper visibility.
In 2.x, it used to be that if you declare nothing in ApplicationController, you get ApplicationHelper and the helper by controller name convention, and you had to say
to make all helpers show everywhere.
However in Rails 3, helper :all is taken as default, and you need to say
in ApplicationController to get the functionality of the previous convention.
See https://rails.lighthouseapp.com/projects/8994/tickets/3945 and https://rails.lighthouseapp.com/projects/8994/tickets/4750
So. I think that ApplicationHelper should always be loaded in helper specs.
Include ApplicationHelper in helper object in helper specs.
- Closes #276.
I don't know if this has been taken into account, but sometimes one defines a function in a certain controller helper that overwrites a function in ApplicationHelper. In such cases, the late inclusion of the ApplicationHelper as it is currently being done breaks the specs.
@TiagoCardoso1983 if you are experiencing a problem then please submit a new issue. Thanks.