|
14 | 14 | include Sus::Fixtures::Console::CapturedLogger |
15 | 15 |
|
16 | 16 | with "#call" do |
17 | | - let(:app) {->(env) {[200, {}, []]}} |
| 17 | + let(:app) {->(env){[200, {}, []]}} |
18 | 18 | let(:adapter) {subject.new(app)} |
19 | 19 |
|
20 | 20 | let(:body) {Protocol::HTTP::Body::Buffered.new} |
21 | 21 | let(:request) {Protocol::HTTP::Request.new("https", "example.com", "GET", "/", "http/1.1", Protocol::HTTP::Headers[{"accept" => "text/html"}], body)} |
22 | 22 | let(:response) {adapter.call(request)} |
23 | 23 |
|
24 | 24 | with "set-cookie headers that has multiple values" do |
25 | | - let(:app) {->(env) {[200, {"set-cookie" => "a=b\nx=y"}, []]}} |
| 25 | + let(:app) {->(env){[200, {"set-cookie" => "a=b\nx=y"}, []]}} |
26 | 26 |
|
27 | 27 | it "can make a response newline separated headers" do |
28 | 28 | expect(response.headers["set-cookie"]).to be == ["a=b", "x=y"] |
29 | 29 | end |
30 | 30 | end |
31 | 31 |
|
32 | 32 | with "content-length header" do |
33 | | - let(:app) {->(env) {[200, {"content-length" => "10"}, ["1234567890"]]}} |
| 33 | + let(:app) {->(env){[200, {"content-length" => "10"}, ["1234567890"]]}} |
34 | 34 |
|
35 | 35 | it "removes content-length header" do |
36 | 36 | expect(response.headers).not.to be(:include?, "content-length") |
37 | 37 | end |
38 | 38 | end |
39 | 39 |
|
40 | 40 | with "connection: close header" do |
41 | | - let(:app) {->(env) {[200, {"connection" => "close"}, []]}} |
| 41 | + let(:app) {->(env){[200, {"connection" => "close"}, []]}} |
42 | 42 |
|
43 | 43 | it "removes content-length header" do |
44 | 44 | expect(response.headers).not.to be(:include?, "connection") |
|
47 | 47 |
|
48 | 48 | with "body that responds to #to_path" do |
49 | 49 | let(:body) {Array.new} |
50 | | - let(:app) {->(env) {[200, {}, body]}} |
| 50 | + let(:app) {->(env){[200, {}, body]}} |
51 | 51 |
|
52 | 52 | it "should generate file body" do |
53 | 53 | expect(body).to receive(:to_path).and_return("/dev/null") |
|
56 | 56 | end |
57 | 57 |
|
58 | 58 | with "206 partial response status" do |
59 | | - let(:app) {->(env) {[200, {}, body]}} |
| 59 | + let(:app) {->(env){[200, {}, body]}} |
60 | 60 |
|
61 | 61 | it "should not modify partial responses" do |
62 | 62 | expect(response.body).to be_a(Protocol::Rack::Body::Enumerable) |
|
75 | 75 |
|
76 | 76 | with "response handling" do |
77 | 77 | with "array response" do |
78 | | - let(:app) {->(env) {[200, {}, ["Hello"]]}} |
| 78 | + let(:app) {->(env){[200, {}, ["Hello"]]}} |
79 | 79 |
|
80 | 80 | it "handles array response correctly" do |
81 | 81 | expect(response.body).to be_a(Protocol::Rack::Body::Enumerable) |
|
85 | 85 |
|
86 | 86 | with "header transformation" do |
87 | 87 | with "array values" do |
88 | | - let(:app) {->(env) {[200, {"x-custom" => "a\nb"}, []]}} |
| 88 | + let(:app) {->(env){[200, {"x-custom" => "a\nb"}, []]}} |
89 | 89 |
|
90 | 90 | it "joins array values with newlines in response" do |
91 | 91 | expect(response.headers["x-custom"]).to be == ["a", "b"] |
92 | 92 | end |
93 | 93 | end |
94 | 94 |
|
95 | 95 | with "non-array values" do |
96 | | - let(:app) {->(env) {[200, {"x-custom" => "value"}, []]}} |
| 96 | + let(:app) {->(env){[200, {"x-custom" => "value"}, []]}} |
97 | 97 |
|
98 | 98 | it "preserves non-array values" do |
99 | 99 | expect(response.headers["x-custom"]).to be == ["value"] |
100 | 100 | end |
101 | 101 | end |
102 | 102 |
|
103 | 103 | with "multiple set-cookie headers" do |
104 | | - let(:app) {->(env) {[200, {"set-cookie" => "a=b\nx=y"}, []]}} |
| 104 | + let(:app) {->(env){[200, {"set-cookie" => "a=b\nx=y"}, []]}} |
105 | 105 |
|
106 | 106 | it "joins set-cookie headers with newlines" do |
107 | 107 | expect(response.headers["set-cookie"]).to be == ["a=b", "x=y"] |
108 | 108 | end |
109 | 109 | end |
110 | 110 |
|
111 | 111 | with "rack specific headers" do |
112 | | - let(:app) {->(env) {[200, {"rack.hijack" => ->(stream){}}, []]}} |
| 112 | + let(:app) {->(env){[200, {"rack.hijack" => ->(stream){}}, []]}} |
113 | 113 |
|
114 | 114 | it "preserves rack specific headers in meta" do |
115 | 115 | expect(response.headers).not.to be(:include?, "rack.hijack") |
|
149 | 149 | let(:adapter) {subject.new(app)} |
150 | 150 |
|
151 | 151 | let(:callback_called) {false} |
152 | | - let(:callback) {->(env, status, headers, exception) {@callback_called = true}} |
| 152 | + let(:callback) {->(env, status, headers, exception){@callback_called = true}} |
153 | 153 | let(:app) do |
154 | 154 | proc do |env| |
155 | 155 | env[Protocol::Rack::RACK_RESPONSE_FINISHED] = [callback] |
|
0 commit comments