From bc98e32952869c765fcb6bdfe31a6c4eaba9baad Mon Sep 17 00:00:00 2001 From: Darren Boyd Date: Mon, 17 Jun 2024 10:20:54 -0700 Subject: [PATCH 1/2] HaveHttpStatus uses Rack's public API Instead of accessing a Constant that isn't a documented part of the Rack API, get the status code for a status name using Rack's supported public API. --- lib/rspec/rails/matchers/have_http_status.rb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/rspec/rails/matchers/have_http_status.rb b/lib/rspec/rails/matchers/have_http_status.rb index 858ef547b..878ceadc7 100644 --- a/lib/rspec/rails/matchers/have_http_status.rb +++ b/lib/rspec/rails/matchers/have_http_status.rb @@ -216,11 +216,7 @@ def pp_status(status, code) # @see Rack::Utils::SYMBOL_TO_STATUS_CODE # @raise [ArgumentError] if an associated code could not be found def set_expected_code! - @expected ||= - Rack::Utils::SYMBOL_TO_STATUS_CODE.fetch(expected_status) do - raise ArgumentError, - "Invalid HTTP status: #{expected_status.inspect}" - end + @expected ||= Rack::Utils.status_code(expected_status) end end From b7ab320b7109ba00fc1599304a12d06b5c37cdfc Mon Sep 17 00:00:00 2001 From: Darren Boyd Date: Tue, 18 Jun 2024 15:08:56 -0700 Subject: [PATCH 2/2] Changelog for #2763 --- Changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Changelog.md b/Changelog.md index e9e4efedd..e538d2c6c 100644 --- a/Changelog.md +++ b/Changelog.md @@ -12,6 +12,7 @@ Bug Fixes: * Reset `ActiveSupport::CurrentAttributes` between examples. (Javier Julio, #2752) * Fix a broken link in generated mailer previews. (Chiara Núñez, #2764) +* Have HttpStatusMatcher use Rack's public API for http status code. (Darren Boyd, #2763) ### 6.1.2 / 2024-03-19 [Full Changelog](https://github.com/rspec/rspec-rails/compare/v6.1.1...v6.1.2)