Skip to content

Commit

Permalink
Restore 100% coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Nov 9, 2024
1 parent 550176f commit a74035b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/protocol/http/body/stream.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@
expect(stream.read_until("o")).to be == "Hello"
expect(stream.read_until("d")).to be == "World"
end

it "can read until a pattern which isn't encountered" do
expect(stream.read_until("X")).to be_nil
end
end

with "#gets" do
Expand All @@ -175,6 +179,10 @@
expect(stream.gets).to be == nil
end

it "can read up until the limit" do
expect(stream.gets("X", 2)).to be == "He"
end

it "can read lines with limit" do
expect(stream.gets(2)).to be == "He"
expect(stream.gets(6)).to be == "llo\n"
Expand All @@ -195,6 +203,15 @@
expect(stream.gets(nil, 4)).to be == "rld\n"
expect(stream.gets(nil, 4)).to be == nil
end

with "several chunks" do
let(:input) {Protocol::HTTP::Body::Buffered.new(["Hello ", "World\n"])}

it "can read lines" do
expect(stream.gets).to be == "Hello World\n"
expect(stream.gets).to be == nil
end
end
end

with "#close_read" do
Expand Down
7 changes: 7 additions & 0 deletions test/protocol/http/body/wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@
end
end

with "#buffered" do
it "should proxy buffered" do
expect(source).to receive(:buffered).and_return(true)
expect(body.buffered).to be == true
end
end

with "#rewindable?" do
it "should proxy rewindable?" do
expect(source).to receive(:rewindable?).and_return(true)
Expand Down

0 comments on commit a74035b

Please sign in to comment.