Skip to content

Commit 50a17d0

Browse files
committed
Add tests.
1 parent 9631fde commit 50a17d0

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

lib/protocol/rack/body.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
require_relative "body/streaming"
77
require_relative "body/enumerable"
88
require_relative "constants"
9+
910
require "protocol/http/body/completable"
11+
require "protocol/http/body/head"
1012

1113
module Protocol
1214
module Rack

test/protocol/rack/body.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
end
1919

2020
with "#wrap" do
21-
let(:env) { {} }
22-
let(:headers) { {} }
21+
let(:env) {Hash.new}
22+
let(:headers) {Hash.new}
2323

2424
it "handles nil body" do
2525
expect(Console).to receive(:warn).and_return(nil)
@@ -28,6 +28,14 @@
2828
expect(result).to be_nil
2929
end
3030

31+
it "handles head request with empty body" do
32+
headers["content-length"] = "123"
33+
34+
result = subject.wrap(env, 200, headers, [], nil, true)
35+
expect(result).to be_a(Protocol::HTTP::Body::Head)
36+
expect(result.length).to be == 123
37+
end
38+
3139
with "non-empty body and no-content status" do
3240
let(:mock_body) do
3341
Protocol::HTTP::Body::Buffered.new(["content"])

0 commit comments

Comments
 (0)