Repository navigation
Draw the routes before the specs run - #703
Merged
Merged
Conversation
Rails 8.0+ puts off drawing the routes until a request first needs them, so the example that makes the suite's first request draws them under its own stubs. When that example is the one in `mount_point_spec.rb`, which replaces the application's deploy with a double, `mount_ember_app` fails on `mountable?`, and on Rails 8.0 the half-drawn routes then fail every later example that needs them. The suite runs in random order, so only some CI jobs hit this. Draw the routes while the suite loads, as earlier versions of Rails do while initializing. Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
`Object#try` hid that the call is skipped on Rails 7.2, which does not define `reload_routes_unless_loaded`. Say so with `respond_to?`. Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
CI on
mainfailed in 2 of 17 jobs (Rails 8.0 and Rails 8.1) afterspec/requests/render_ember_app/mount_point_spec.rbwas added:Rails 8.0+ puts off drawing the routes until a request first needs them. The suite runs in random order, so whichever example makes the first request draws the routes under its own stubs.
mount_point_spec.rbreplaces the application's deploy with a double that only answersindex_html, andmount_ember_appasks the deploy whether it ismountable?— so when that example goes first, drawing the routes fails.On Rails 8.0 the routes are then left half-drawn, which is why that job reported 11 failures (missing path helpers, 404s) rather than one.
Fix
Draw the routes while the suite loads, as Rails 7.2 does while initializing, so no example draws them under its stubs.
reload_routes_unless_loadeddoes not exist on Rails 7.2, hence therespond_to?check.Verification
Running
rspec spec/requests/render_ember_app/mount_point_spec.rbon its own (so that it makes the first request) with Ruby 3.4:I did not run the full suite locally; that is left to CI here.
🤖 Generated with Claude Code