Remove unnecessary routing assertions require #2732
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
ActionDispatch::Assertions
has an autoload defined: https://github.com/rails/rails/blob/v7.1.3/actionpack/lib/action_dispatch.rb#L130That file requires
action_dispatch/testing/assertions/routing.rb
:https://github.com/rails/rails/blob/v7.1.3/actionpack/lib/action_dispatch/testing/assertions.rb#L5
So
ActionDispatch::Assertions::RoutingAssertions
can be referenced without being explicitly required.rspec/rails/example/controller_example_group.rb
, which is loaded before this file, already references it and triggers the autoload, which means this require never has any effect:https://github.com/rspec/rspec-rails/blob/v6.1.1/lib/rspec/rails/example/controller_example_group.rb#L5
Requiring
action_dispatch/testing/assertions/routing.rb
on its own doesn't actually work, because it autoloadsActionDispatch::Assertions
which then fails to findActionDispatch::Assertions::RoutingAssertions
since it hasn't been defined yet:(This is a prerequisite to a larger change, but I wanted to propose it first since it requires a fair bit of explanation.)