Skip to content

Draw the routes before the specs run - #703

Merged
tricknotes merged 2 commits into
mainfrom
draw-routes-before-specs
Nov 17, 2026
Merged

tricknotes merged 2 commits into
mainfrom
draw-routes-before-specs

Conversation

@tricknotes

@tricknotes tricknotes commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

Problem

CI on main failed in 2 of 17 jobs (Rails 8.0 and Rails 8.1) after spec/requests/render_ember_app/mount_point_spec.rb was added:

#<Double (anonymous)> received unexpected message :mountable? with (no args)

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.rb replaces the application's deploy with a double that only answers index_html, and mount_ember_app asks the deploy whether it is mountable? — 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_loaded does not exist on Rails 7.2, hence the respond_to? check.

Verification

Running rspec spec/requests/render_ember_app/mount_point_spec.rb on its own (so that it makes the first request) with Ruby 3.4:

Rails Before After
8.0.5.2 fails passes
7.2.3 — passes
8.1.4.1 — passes

I did not run the full suite locally; that is left to CI here.

🤖 Generated with Claude Code

tricknotes and others added 2 commits November 18, 2026 01:39
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>
@tricknotes
tricknotes merged commit 310793a into main Nov 17, 2026
17 checks passed
@tricknotes
tricknotes deleted the draw-routes-before-specs branch November 17, 2026 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant