Skip to content

Commit

Permalink
add test if io throws error
Browse files Browse the repository at this point in the history
  • Loading branch information
AndriiAndreiev committed Aug 29, 2024
1 parent 27e757e commit 14554e7
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/ruby/spec/readme/http_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,16 @@
expect(request.body).to eq '[BODY]'
expect(request.body).to eq '[BODY]'
end

it 'returns an empty string if an error occurs while reading the body' do
io = instance_double(StringIO, read: nil)
allow(io).to receive(:rewind).and_raise(StandardError.new("Test Error"))

env = { 'rack.input' => io }
request = described_class.new(env)

expect(request.body).to eq ''
end
end

describe '#parsed_form_data' do
Expand Down

0 comments on commit 14554e7

Please sign in to comment.