Skip to content
This repository was archived by the owner on Aug 29, 2024. It is now read-only.

Commit 233db7e

Browse files
committed
Fix tests
1 parent b1c72f9 commit 233db7e

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

Diff for: lib/async/io/stream.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ def peek(size = nil)
134134
# Don't read less than @block_size to avoid lots of small reads:
135135
fill_read_buffer(read_size > @block_size ? read_size : @block_size)
136136
end
137-
return @read_buffer[..[size, @read_buffer.size].min]
137+
return @read_buffer[..([size, @read_buffer.size].min - 1)]
138138
end
139-
until yield(@read_buffer) or @eof
139+
until (block_given? && yield(@read_buffer)) or @eof
140140
fill_read_buffer
141141
end
142142
end

Diff for: spec/async/io/stream_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@
215215
io.write "Hello World"
216216
io.seek(0)
217217

218-
expect(subject.io).to receive(:read_nonblock).and_call_original.once
218+
expect(subject.io).to receive(:read_nonblock).and_call_original.twice
219219

220220
expect(subject.peek(400)).to be == "Hello World"
221221
expect(subject.read_partial(400)).to be == "Hello World"

0 commit comments

Comments
 (0)