ApplicationHelper is not loaded in helper specs #276

livedo opened this Issue Nov 30, 2010 · 6 comments


None yet

3 participants

livedo commented Nov 30, 2010

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

module ApplicationHelper
  def test_helper_method

and a helper method which calls another helper method defined in the ApplicationHelper

module TestingHelper
  def generic_helper_caller

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'
 # ./spec/helpers/testing_helper_spec.rb:16
livedo commented Dec 1, 2010

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.


livedo commented Dec 1, 2010

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
helper :all
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 and

So. I think that ApplicationHelper should always be loaded in helper specs.


Include ApplicationHelper in helper object in helper specs.



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.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment