Skip to content

Commit 7a8850e

Browse files
Update error-during-body-write test for protocol-http1 v0.37.1.
1 parent 7c30830 commit 7a8850e

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

test/async/http/protocol/http11.rb

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,28 @@
1313
# Custom error class to track in tests
1414
class BodyWriteError < StandardError; end
1515

16-
# A custom body class that raises during enumeration.
16+
# A custom body class that raises during reading.
1717
class ErrorProneBody < ::Protocol::HTTP::Body::Readable
1818
def initialize(...)
1919
super(...)
2020

2121
@error = nil
22+
@count = 0
2223
end
2324

2425
attr :error
2526

27+
def read
28+
@count += 1
29+
raise BodyWriteError, "error during write" if @count > 1
30+
31+
"Hello"
32+
end
33+
2634
def close(error = nil)
2735
@error = error
2836
super()
2937
end
30-
31-
def each
32-
super
33-
raise BodyWriteError, "error during write"
34-
end
3538
end
3639

3740
describe Async::HTTP::Protocol::HTTP11 do
@@ -70,7 +73,6 @@ def each
7073

7174
let(:app) do
7275
Protocol::HTTP::Middleware.for do |request|
73-
# Return a response with a body that will raise during enumeration:
7476
Protocol::HTTP::Response[200, {}, body]
7577
end
7678
end

0 commit comments

Comments
 (0)