Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

helper(:all) raises error in an ActionView::TestCase

#4775
# test/helpers/gadgets_helper_test.rb
require 'test_helper'

class GadgetsHelperTest < ActionView::TestCase
  helper :all

  test "something" do
    # ...
  end
end

Running this yields the following error:

rails/activesupport/lib/active_support/dependencies.rb:277:in `depend_on': Missing helper file helpers/all_helper.rb (LoadError)

Here's the full backtrace:

$ rake test:units
(in /Users/dchelimsky/projects/ruby/rspec2/repos/rspec-rails/tmp/example_app)
/Users/dchelimsky/projects/ruby/rspec2/repos/rspec-rails/tmp/rails/activesupport/lib/active_support/dependencies.rb:277:in `depend_on': Missing helper file helpers/all_helper.rb (LoadError)
    from /Users/dchelimsky/projects/ruby/rspec2/repos/rspec-rails/tmp/rails/activesupport/lib/active_support/dependencies.rb:189:in `require_dependency'
    from /Users/dchelimsky/projects/ruby/rspec2/repos/rspec-rails/tmp/rails/actionpack/lib/abstract_controller/helpers.rb:131:in `modules_for_helpers'
    from /Users/dchelimsky/projects/ruby/rspec2/repos/rspec-rails/tmp/rails/actionpack/lib/abstract_controller/helpers.rb:127:in `map!'
    from /Users/dchelimsky/projects/ruby/rspec2/repos/rspec-rails/tmp/rails/actionpack/lib/abstract_controller/helpers.rb:127:in `modules_for_helpers'
    from /Users/dchelimsky/projects/ruby/rspec2/repos/rspec-rails/tmp/rails/actionpack/lib/abstract_controller/helpers.rb:91:in `helper'
    from ./test/unit/helpers/gadgets_helper_test.rb:4

helper(:all) works in controllers because controllers include ActionController::Metal::Helpers, but ActionView::TestCase::Behavior does not do the same.

I started to look at patching ActionView::TestCase::Behavior to include ActionController::Metal::Helpers, and got this very interesting error:

$ rake test:units
(in /Users/dchelimsky/projects/ruby/rspec2/repos/rspec-rails/tmp/example_app)
/Users/dchelimsky/projects/ruby/rspec2/repos/rspec-rails/tmp/rails/activesupport/lib/active_support/dependencies.rb:443:in `load_missing_constant': ActionController is not missing constant Helpers! (ArgumentError)

I'll continue to look at this, but I wanted to get this documented in the mean time.

Reported by David Chelimsky · June 6th, 2010 @ 12:20 PM

State: stale
Milestone: none
Assigned to: Yehuda Katz (wycats) Yehuda Katz (wycats)
Importance: none

Activity

  1. David Chelimsky
    David Chelimsky
    • Assigned user changed from Yehuda Katz (wycats) to José Valim

    June 6th, 2010 @ 12:20 PM

  2. David Chelimsky
    David Chelimsky

    The documentation in AbstractController::Helpers is misleading. It says that you can say helper(:all), but that only works in classes that also include ActionController::Metal::Helpers, which overrides helper, decorating it with support for :all.

    June 6th, 2010 @ 12:28 PM

  3. David Chelimsky
    David Chelimsky
    • Assigned user changed from José Valim to Yehuda Katz (wycats)

    June 21st, 2010 @ 05:52 PM

  4. Santiago Pastorino
    Santiago Pastorino
    • State changed from new to open

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

    February 2nd, 2011 @ 05:02 PM

  5. Santiago Pastorino
    Santiago Pastorino
    • State changed from open to stale

    February 2nd, 2011 @ 05:02 PM