Skip to content

Commit

Permalink
Mock HTTP::Connection#finished_request?
Browse files Browse the repository at this point in the history
  • Loading branch information
c960657 committed Aug 1, 2024
1 parent a7bb2fc commit 2f8b9e0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/webmock/http_lib_adapters/http_rb/streamer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ def close
@io.close
end

def finished_request?
@io.eof?
end

def sequence_id
-1
end
Expand Down
14 changes: 14 additions & 0 deletions spec/acceptance/http_rb/http_rb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,20 @@

response.connection.close
end

it "reports request finish" do
stub_request(:get, "example.com/foo")
.to_return(body: 'XX')
response = HTTP.get "http://example.com/foo"

expect(response.connection.finished_request?).to be(false)

response.body.readpartial(1)
expect(response.connection.finished_request?).to be(false)

response.body.readpartial
expect(response.connection.finished_request?).to be(true)
end
end

it "should preserve request body encoding when matching requests" do
Expand Down

0 comments on commit 2f8b9e0

Please sign in to comment.