-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed as not planned
Description
What Ruby, Rails and RSpec versions are you using?
Ruby version: 3.4.2
Rails version: 8.0.2
RSpec version: 3.13.3
RSpec Rails version: 7.1.1
Not sure if this belongs here or in rspec-core
Observed behaviour
When running full test suite with rspec spec or rake , tests use wrong url_for helper without access to routes. It results in the following error whenever link_to or similar code is used (e.g. in views):
ActionView::Template::Error:
arguments passed to url_for can't be handled. Please require routes or provide your own implementation
Everything works fine when running a single type of tests with rspec spec/requests.
BAD, full test suite:
actionview-8.0.1/lib/action_view/helpers/url_helper.rb
def url_for(options = nil) # :nodoc:
case options
when String
options
when :back
_back_url
else
raise ArgumentError, "arguments passed to url_for can't be handled. Please require " \
"routes or provide your own implementation"
end
endvs GOOD, subdirectory of spec
actionview-8.0.1/lib/action_view/routing_url_for.rb
def url_for(options = nil)
# ...
if options[:only_path]
polymorphic_path(components, options)
else
polymorphic_url(components, options)
end
else
method = _generate_paths_by_default ? :path : :url
builder = ActionDispatch::Routing::PolymorphicRoutes::HelperMethodBuilder.public_send(method)
# ...
end
endExpected behaviour
In all cases test should have access to Rails routes.
Metadata
Metadata
Assignees
Labels
No labels