Skip to content

Support Rails 8.1 / Ruby 4.0.5#1

Open
lleirborras wants to merge 2 commits into
masterfrom
upgrade/rails-8.1-ruby-4
Open

Support Rails 8.1 / Ruby 4.0.5#1
lleirborras wants to merge 2 commits into
masterfrom
upgrade/rails-8.1-ruby-4

Conversation

@lleirborras

Copy link
Copy Markdown
Member

Summary

Makes user_error load and run on Rails 8.1 / Ruby 4.0.5 while staying compatible with the older stack consumers are on today (down to Rails 6.1 / Ruby 2.7). Part of the fleet Rails 8.1 / Ruby 4 upgrade — about 7 apps depend on this engine.

What changed

  • render nothing: truehead. ExceptionsController#show used render nothing: true for the catch-all response format; that was removed in Rails 5.1. Now head @status_code.
  • Bare env reader → request.env. The controller read the request env via the env method on ActionController::Metal, which has been removed. Both replacements work on every supported Rails version.
  • Drop the bundler "~> 1.3" development pin — it forced Bundler 1.x and blocked bundle install on current toolchains. No required_ruby_version cap (consumers span Ruby 2.x → 4.0).

Test suite

The old suite was capybara feature specs against spec/dummy — a Rails 3/4-era app (secret_token.rb, wrap_parameters) that can't boot on modern Rails, and one committed dummy can't span Rails 6.1 → 8.1. Replaced with rspec request specs that boot a minimal app in spec_helper and drive the exceptions_app directly, covering the same intent:

  • 404 (missing resource), 500 (server error)
  • 500 in JSON / XML / and the catch-all format returning an empty head
  • a custom exception mapped through the rescue_from DSL → 403

spec/dummy is removed (including some *.sqlite3 binaries that had been committed). Dev deps slimmed to rspec + rake (no rspec-rails / capybara / DB / nokogiri needed).

How to test

CI runs rspec + the smoke across the matrix: Ruby 4.0.5 / 3.4 × Rails 8.1, Ruby 3.4 × Rails 7.2, Ruby 2.7 × Rails 6.1.

Locally: BUNDLE_GEMFILE=test/Gemfile.ci bundle install && BUNDLE_GEMFILE=test/Gemfile.ci bundle exec rspec.

Verified green (rspec + smoke) on Ruby 4.0.5 / 3.4 (Rails 8.1), Ruby 3.3 (Rails 7.1) and Ruby 2.7 (Rails 6.1).

Risks / follow-ups

  • i18n is held at < 1.15 on Ruby < 3.2 in the test bundle — 1.15's Fiber storage needs Ruby 3.2+. Test-only; doesn't affect the gem's runtime deps.
  • The specs drive the exceptions_app directly rather than through a full HTTP round-trip; that's the layer user_error actually plugs into, so it's the right surface to assert.

lleirborras and others added 2 commits June 19, 2026 09:32
Two blockers in ExceptionsController#show removed in modern Rails:

- `render nothing: true` (gone since Rails 5.1) -> `head` for the
  catch-all response format.
- the bare `env` reader on ActionController::Metal (removed) -> `request.env`.

Both replacements work on every supported Rails version, so consumers
still on the old stack are unaffected.

Drop the `bundler "~> 1.3"` development pin, which forced Bundler 1.x and
blocked `bundle install` on current toolchains. No required Ruby/Rails
upper bound: consumers span Ruby 2.x through 4.0.

Add a self-contained smoke harness (test/smoke.rb) that wires the engine
as the exceptions_app and drives the controller for html/json/xml plus the
catch-all head path, with a CI matrix sweeping Ruby 4.0.5/3.4/2.7 across
Rails 8.1/7.2/6.1. Verified green on Ruby 4.0.5 + Rails 8.1 and on the
Ruby 2.7 + Rails 6.1 backward-compat row.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The suite was capybara feature specs against spec/dummy — a Rails 3/4-era app
(secret_token.rb, wrap_parameters) that can't boot on modern Rails, and a single
committed dummy can't span Rails 6.1 → 8.1. Replace it with rspec request specs
that boot a minimal app in spec_helper and drive the exceptions_app directly,
covering the same intent: 404, 500 (html/json/xml + the catch-all head), and a
custom exception mapped through the rescue_from DSL.

- Remove spec/dummy entirely (incl. accidentally committed *.sqlite3 binaries).
- spec_helper boots a minimal Rails app (no DB, plain ERB views), so the suite
  runs unchanged on Ruby 2.7 → 4.0.5 / Rails 6.1 → 8.1.
- Slim dev deps: drop rspec-rails / capybara / sqlite3 (no Rails integration
  harness, no DB) and nokogiri (assert XML as a string); keep rspec + rake.
- test/Gemfile.ci pulls dev deps via `gemspec`; hold i18n < 1.15 on Ruby < 3.2
  (its Fiber storage needs Ruby 3.2+). Run rspec + smoke in CI; checkout @v6.

Verified green (rspec + smoke) on Ruby 4.0.5/3.4 (Rails 8.1), Ruby 3.3
(Rails 7.1) and Ruby 2.7 (Rails 6.1).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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