Support Rails 8.1 / Ruby 4.0.5#1
Open
lleirborras wants to merge 2 commits into
Open
Conversation
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>
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.
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: true→head.ExceptionsController#showusedrender nothing: truefor the catch-all response format; that was removed in Rails 5.1. Nowhead @status_code.envreader →request.env. The controller read the request env via theenvmethod onActionController::Metal, which has been removed. Both replacements work on every supported Rails version.bundler "~> 1.3"development pin — it forced Bundler 1.x and blockedbundle installon current toolchains. Norequired_ruby_versioncap (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 inspec_helperand drive theexceptions_appdirectly, covering the same intent:headrescue_fromDSL → 403spec/dummyis removed (including some*.sqlite3binaries that had been committed). Dev deps slimmed torspec+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
i18nis held at< 1.15on 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.exceptions_appdirectly 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.