Skip to content

Commit a74035b

Browse files
committed
Restore 100% coverage.
1 parent 550176f commit a74035b

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

test/protocol/http/body/stream.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@
164164
expect(stream.read_until("o")).to be == "Hello"
165165
expect(stream.read_until("d")).to be == "World"
166166
end
167+
168+
it "can read until a pattern which isn't encountered" do
169+
expect(stream.read_until("X")).to be_nil
170+
end
167171
end
168172

169173
with "#gets" do
@@ -175,6 +179,10 @@
175179
expect(stream.gets).to be == nil
176180
end
177181

182+
it "can read up until the limit" do
183+
expect(stream.gets("X", 2)).to be == "He"
184+
end
185+
178186
it "can read lines with limit" do
179187
expect(stream.gets(2)).to be == "He"
180188
expect(stream.gets(6)).to be == "llo\n"
@@ -195,6 +203,15 @@
195203
expect(stream.gets(nil, 4)).to be == "rld\n"
196204
expect(stream.gets(nil, 4)).to be == nil
197205
end
206+
207+
with "several chunks" do
208+
let(:input) {Protocol::HTTP::Body::Buffered.new(["Hello ", "World\n"])}
209+
210+
it "can read lines" do
211+
expect(stream.gets).to be == "Hello World\n"
212+
expect(stream.gets).to be == nil
213+
end
214+
end
198215
end
199216

200217
with "#close_read" do

test/protocol/http/body/wrapper.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@
6060
end
6161
end
6262

63+
with "#buffered" do
64+
it "should proxy buffered" do
65+
expect(source).to receive(:buffered).and_return(true)
66+
expect(body.buffered).to be == true
67+
end
68+
end
69+
6370
with "#rewindable?" do
6471
it "should proxy rewindable?" do
6572
expect(source).to receive(:rewindable?).and_return(true)

0 commit comments

Comments
 (0)