Skip to content

Commit

Permalink
Fix pipe IO rewind specs
Browse files Browse the repository at this point in the history
  • Loading branch information
ixti committed Feb 15, 2019
1 parent 0285f99 commit f311078
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions spec/lib/http/request/body_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,21 @@
let(:ios) { IO.pipe }
let(:body) { ios[0] }

before do
Thread.new(ios[1]) do |io|
16_384.times { io << "abcdef" }
around do |example|
writer = Thread.new(ios[1]) do |io|
io << "abcdef"
io.close
end

begin
example.run
ensure
writer.join
end
end

it "yields chunks of content" do
expect(chunks.inject("", :+)).to eq("abcdef" * 16_384)
expect(chunks.inject("", :+)).to eq("abcdef")
end
end

Expand Down

0 comments on commit f311078

Please sign in to comment.