Skip to content

Commit

Permalink
HaveHttpStatus uses Rack's public API
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
darrenboyd committed Jun 17, 2024
1 parent e65348e commit 8d3b0f8
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions lib/rspec/rails/matchers/have_http_status.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 8d3b0f8

Please sign in to comment.