This project is archived and is in readonly mode.
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
-
Jeremy Kemper November 9th, 2009 @ 05:17 AM
- Milestone cleared.
- Assigned user set to josh
-
josh November 9th, 2009 @ 08:50 PM
- State changed from new to open
-
Repository November 10th, 2009 @ 03:38 AM
- State changed from open to resolved
(from [1004fcb76761aa42ff18d8aa373614a41a259d3c]) Fixed AD assertion autoloads [#3470 state:resolved] http://github.com/rails/rails/commit/1004fcb76761aa42ff18d8aa373614...
-
josh November 10th, 2009 @ 03:39 AM
Try that.
Also, you should not be using require here. Just reference that const and let the autoload work. Requiring 'action_dispatch/testing/assertions/selector' is not "public api".
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
- 3470 Cannot require ActionDispatch SelectorAssertions (from [1004fcb76761aa42ff18d8aa373614a41a259d3c]) Fixed A...