-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Description
What Ruby, Rails and RSpec versions are you using?
Ruby version: 3.3.3
Rails version: 7.1.3.4
RSpec version: 3.13.0
Rack version: 3.1.3
Observed behaviour
Rack has recently changed the name of the 422 status code from unprocessable_entity to unprocessable_content. However, both names will still resolve if Rack's public API is being used. However, the HttpStatusMatcher is looking at the Rack Constant directly, instead of using the provided API.
My suggestion is for the code in have_http_status.rb that looks like (around line 218)...
def set_expected_code!
@expected ||=
Rack::Utils::SYMBOL_TO_STATUS_CODE.fetch(expected_status) do
raise ArgumentError,
"Invalid HTTP status: #{expected_status.inspect}"
end
endbe changed to....
def set_expected_code!
@expected ||= Rack::Utils.status_code(expected_status)
endHere's the behavior of the Rack::Utils.status_code method...
irb> Rack::Utils.status_code(:unprocessable_content)
=> 422
irb> Rack::Utils.status_code(:unprocessable_entity)
=> 422
irb> Rack::Utils.status_code(:invalidcode)
(irb):4:in `<main>': Unrecognized status code :invalidcode (ArgumentError)
aki77, viralpraxis, yenshirak, kg-currenxie, cheister and 12 moreIvanov-Anton
Metadata
Metadata
Assignees
Labels
No labels