This project is archived and is in readonly mode.

#3470 ✓resolved
Mislav

Cannot require ActionDispatch SelectorAssertions

Reported by Mislav | November 9th, 2009 @ 12:00 AM | in 3.0.2

I tried to load and mix in ActionDispatch::Assertions::SelectorAssertions in my specs:

require 'action_dispatch/testing/assertions/selector'

This fails with "ActionDispatch::Assertions::SelectorAssertions is an undefined constant". Of course it's undefined; I'm trying to require a file that defines it! This weird error seemed to originate from the very second line of code in that file:

module ActionDispatch
  module Assertions # <-- this one
    ...
  end
end

Turns out, ActionDisplatch has set "Assertions" constant to autoload 'action_dispatch/testing/assertions', which in turn tries to load all its submodules, which tries to mix in ActionDispatch::Assertions::SelectorAssertions before it's even defined. The solution was to simply load the complete assertions module:

require 'action_dispatch/testing/assertions'

I have no idea how to solve this without getting rid of the autoload, but Rails 3 should make every independent component of it loadable and I think this should definitely fall under that category.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Referenced by

Pages