|
18 | 18 | end |
19 | 19 |
|
20 | 20 | with "#wrap" do |
21 | | - let(:env) { {} } |
22 | | - let(:headers) { {} } |
| 21 | + let(:env) {Hash.new} |
| 22 | + let(:headers) {Hash.new} |
23 | 23 |
|
24 | 24 | it "handles nil body" do |
25 | 25 | expect(Console).to receive(:warn).and_return(nil) |
|
28 | 28 | expect(result).to be_nil |
29 | 29 | end |
30 | 30 |
|
| 31 | + with "head request" do |
| 32 | + it "handles head request with content-length and empty body" do |
| 33 | + headers["content-length"] = "123" |
| 34 | + |
| 35 | + result = subject.wrap(env, 200, headers, [], nil, true) |
| 36 | + |
| 37 | + expect(result).to be_a(Protocol::HTTP::Body::Head) |
| 38 | + expect(result.length).to be == 123 |
| 39 | + end |
| 40 | + |
| 41 | + it "handles head request with no content-length and empty body" do |
| 42 | + result = subject.wrap(env, 200, headers, [], nil, true) |
| 43 | + |
| 44 | + expect(result).to be_a(Protocol::HTTP::Body::Head) |
| 45 | + expect(result.length).to be == 0 |
| 46 | + end |
| 47 | + |
| 48 | + it "handles head request with content-length and nil body" do |
| 49 | + headers["content-length"] = "123" |
| 50 | + |
| 51 | + expect(Console).to receive(:warn).and_return(nil) |
| 52 | + result = subject.wrap(env, 200, headers, nil, nil, true) |
| 53 | + |
| 54 | + expect(result).to be_a(Protocol::HTTP::Body::Head) |
| 55 | + expect(result.length).to be == 123 |
| 56 | + end |
| 57 | + |
| 58 | + it "handles head request with no content-length and nil body" do |
| 59 | + expect(Console).to receive(:warn).and_return(nil) |
| 60 | + |
| 61 | + result = subject.wrap(env, 200, headers, nil, nil, true) |
| 62 | + |
| 63 | + expect(result).to be_nil |
| 64 | + end |
| 65 | + end |
| 66 | + |
31 | 67 | with "non-empty body and no-content status" do |
32 | 68 | let(:mock_body) do |
33 | 69 | Protocol::HTTP::Body::Buffered.new(["content"]) |
|
0 commit comments