Skip to content

Commit

Permalink
add test to cover if a response body is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
ma2gedev committed Aug 2, 2024
1 parent 6083f1d commit 5dfe9ce
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions spec/faraday/encoding_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
stub.get('/redirected') do
[redirected_status, redirected_headers, redirected_body]
end
stub.post('/post') do
[post_response_status, post_response_headers, post_response_body]
end
end
end

Expand Down Expand Up @@ -109,4 +112,18 @@
expect(response.body.encoding).to eq(Encoding::ASCII_8BIT)
end
end

context 'ignore with an empty body' do
let(:post_response_status) { 204 }
let(:post_response_headers) do
{ 'content-type' => "text/plain; charset=utf-8" }
end
let(:post_response_body) do
nil
end

it 'skips `force_encoding`' do
expect { client.post('/post') }.not_to raise_error
end
end
end

0 comments on commit 5dfe9ce

Please sign in to comment.