Skip to content

Commit 16655cb

Browse files
Add test for non-rewindable inputs.
1 parent 0fd909e commit 16655cb

File tree

1 file changed

+27
-10
lines changed

1 file changed

+27
-10
lines changed

test/protocol/rack/input.rb

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,6 @@
5252
expect(input).to be(:closed?)
5353
end
5454

55-
it "can rewind after reading all input" do
56-
expect(input.read).to be == sample_data.join
57-
expect(input).to be(:closed?)
58-
59-
input.rewind
60-
61-
expect(input).not.to be(:closed?)
62-
expect(input.read).to be == sample_data.join
63-
end
64-
6555
it "can read exactly the content length" do
6656
expect(body).to receive(:close)
6757

@@ -155,6 +145,33 @@
155145
expect(input).not.to be(:closed?)
156146
end
157147
end
148+
149+
with "#rewind" do
150+
it "can rewind after reading all input" do
151+
expect(input.read).to be == sample_data.join
152+
expect(input).to be(:closed?)
153+
154+
input.rewind
155+
156+
expect(input).not.to be(:closed?)
157+
expect(input.read).to be == sample_data.join
158+
end
159+
160+
it "can rewind after reading partial input" do
161+
expect(input.read(3)).to be == "The"
162+
expect(input).not.to be(:closed?)
163+
164+
input.rewind
165+
166+
expect(input).not.to be(:closed?)
167+
expect(input.read(3)).to be == "The"
168+
end
169+
170+
it "can't rewind after explicit close" do
171+
input.close
172+
expect(input.rewind).to be == false
173+
end
174+
end
158175
end
159176

160177
with "no body" do

0 commit comments

Comments
 (0)