|
9 | 9 | describe Protocol::Rack::Rewindable do
|
10 | 10 | let(:headers) {Protocol::HTTP::Headers.new}
|
11 | 11 | let(:body) {Protocol::HTTP::Body::Readable.new}
|
12 |
| - let(:app) { |
13 |
| - app = Object.new |
14 |
| - mock(app) do |mock| |
15 |
| - mock.replace(:call) do |request| |
16 |
| - Protocol::HTTP::Response[200, {}, []] |
17 |
| - end |
| 12 | + |
| 13 | + let(:app) do |
| 14 | + proc do |request| |
| 15 | + Protocol::HTTP::Response[200, {}, []] |
18 | 16 | end
|
19 |
| - app |
20 |
| - } |
| 17 | + end |
| 18 | + |
| 19 | + let(:rewindable) {subject.new(app)} |
21 | 20 |
|
22 | 21 | with "non-POST requests" do
|
23 | 22 | it "should rewind if it has a buffered media type" do
|
|
26 | 25 | )
|
27 | 26 | request.headers["content-type"] = "application/x-www-form-urlencoded"
|
28 | 27 |
|
29 |
| - rewindable = subject.new(nil) |
30 | 28 | expect(rewindable.needs_rewind?(request)).to be == true
|
31 | 29 | end
|
32 | 30 | end
|
|
37 | 35 | "https", "example.com", "POST", "/", "HTTP/1.1", headers, body
|
38 | 36 | )
|
39 | 37 |
|
40 |
| - rewindable = subject.new(nil) |
41 | 38 | expect(rewindable.needs_rewind?(request)).to be == true
|
42 | 39 | end
|
43 | 40 |
|
|
47 | 44 | )
|
48 | 45 | request.headers["content-type"] = "application/x-www-form-urlencoded"
|
49 | 46 |
|
50 |
| - rewindable = subject.new(nil) |
51 | 47 | expect(rewindable.needs_rewind?(request)).to be == true
|
52 | 48 | end
|
53 | 49 |
|
|
57 | 53 | )
|
58 | 54 | request.headers["content-type"] = "multipart/form-data; boundary=----WebKitFormBoundary"
|
59 | 55 |
|
60 |
| - rewindable = subject.new(nil) |
61 | 56 | expect(rewindable.needs_rewind?(request)).to be == true
|
62 | 57 | end
|
63 | 58 |
|
|
67 | 62 | )
|
68 | 63 | request.headers["content-type"] = "multipart/related; boundary=----WebKitFormBoundary"
|
69 | 64 |
|
70 |
| - rewindable = subject.new(nil) |
71 | 65 | expect(rewindable.needs_rewind?(request)).to be == true
|
72 | 66 | end
|
73 | 67 |
|
|
77 | 71 | )
|
78 | 72 | request.headers["content-type"] = "multipart/mixed; boundary=----WebKitFormBoundary"
|
79 | 73 |
|
80 |
| - rewindable = subject.new(nil) |
81 | 74 | expect(rewindable.needs_rewind?(request)).to be == true
|
82 | 75 | end
|
83 | 76 |
|
|
87 | 80 | )
|
88 | 81 | request.headers["content-type"] = "application/json"
|
89 | 82 |
|
90 |
| - rewindable = subject.new(nil) |
91 | 83 | expect(rewindable.needs_rewind?(request)).to be == false
|
92 | 84 | end
|
93 | 85 | end
|
|
99 | 91 | )
|
100 | 92 | request.headers["content-type"] = "application/x-www-form-urlencoded"
|
101 | 93 |
|
102 |
| - rewindable = subject.new(app) |
103 | 94 | rewindable.call(request)
|
104 | 95 |
|
105 | 96 | expect(request.body).to be_a(Protocol::HTTP::Body::Rewindable)
|
|
112 | 103 | )
|
113 | 104 | request.headers["content-type"] = "application/json"
|
114 | 105 |
|
115 |
| - rewindable = subject.new(app) |
116 | 106 | rewindable.call(request)
|
117 | 107 |
|
118 | 108 | expect(request.body).to be == body
|
|
0 commit comments