File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed
Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change 164164 expect ( stream . read_until ( "o" ) ) . to be == "Hello"
165165 expect ( stream . read_until ( "d" ) ) . to be == "World"
166166 end
167+
168+ it "can read until a pattern which isn't encountered" do
169+ expect ( stream . read_until ( "X" ) ) . to be_nil
170+ end
167171 end
168172
169173 with "#gets" do
175179 expect ( stream . gets ) . to be == nil
176180 end
177181
182+ it "can read up until the limit" do
183+ expect ( stream . gets ( "X" , 2 ) ) . to be == "He"
184+ end
185+
178186 it "can read lines with limit" do
179187 expect ( stream . gets ( 2 ) ) . to be == "He"
180188 expect ( stream . gets ( 6 ) ) . to be == "llo\n "
195203 expect ( stream . gets ( nil , 4 ) ) . to be == "rld\n "
196204 expect ( stream . gets ( nil , 4 ) ) . to be == nil
197205 end
206+
207+ with "several chunks" do
208+ let ( :input ) { Protocol ::HTTP ::Body ::Buffered . new ( [ "Hello " , "World\n " ] ) }
209+
210+ it "can read lines" do
211+ expect ( stream . gets ) . to be == "Hello World\n "
212+ expect ( stream . gets ) . to be == nil
213+ end
214+ end
198215 end
199216
200217 with "#close_read" do
Original file line number Diff line number Diff line change 6060 end
6161 end
6262
63+ with "#buffered" do
64+ it "should proxy buffered" do
65+ expect ( source ) . to receive ( :buffered ) . and_return ( true )
66+ expect ( body . buffered ) . to be == true
67+ end
68+ end
69+
6370 with "#rewindable?" do
6471 it "should proxy rewindable?" do
6572 expect ( source ) . to receive ( :rewindable? ) . and_return ( true )
You can’t perform that action at this time.
0 commit comments