From 7909cffd8c47c1efe70a25e804927f56ec1ca1b4 Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Thu, 5 Sep 2024 20:04:21 +1200 Subject: [PATCH] Allow file to use `IO.copy_stream`. --- test/protocol/http/body/file.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/protocol/http/body/file.rb b/test/protocol/http/body/file.rb index 101d282..0d6db61 100644 --- a/test/protocol/http/body/file.rb +++ b/test/protocol/http/body/file.rb @@ -74,4 +74,26 @@ expect(body.read).to be == "ll" end end + + with "#call" do + let(:output) {StringIO.new} + + it "can stream output" do + body.call(output) + + expect(output.string).to be == "Hello World" + end + + with "/dev/zero" do + it "can stream partial output" do + skip unless File.exist?('/dev/zero') + + body = subject.open('/dev/zero', 0...10) + + body.call(output) + + expect(output.string).to be == "\x00" * 10 + end + end + end end