Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.4.1
3.4.7
4 changes: 3 additions & 1 deletion lib/openapi_contracts/rspec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@

def with_http_status(status)
if status.is_a? Symbol
@status = Rack::Utils::SYMBOL_TO_STATUS_CODE[status]
@status = Rack::Utils::SYMBOL_TO_STATUS_CODE.fetch(status) do
raise ArgumentError, "Unknown status #{status.inspect}"
end
else
@status = status
end
Expand Down
8 changes: 8 additions & 0 deletions spec/integration/rspec_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,14 @@
it { is_expected.to match_openapi_doc(doc).with_http_status(:bad_request) }
end

context 'when using unsupported status' do
it {
expect {
expect(subject).to match_openapi_doc(doc).with_http_status(:does_not_exist_in_rack)
}.to raise_error(ArgumentError, 'Unknown status :does_not_exist_in_rack')
}
end

context 'when using dynamic paths' do
let(:path) { '/messages/ef278ab2' }
let(:response_json) do
Expand Down