spec/async/io/stream_spec.rb in async-io-1.27.1 vs spec/async/io/stream_spec.rb in async-io-1.27.2
- old
+ new
@@ -44,9 +44,40 @@
let(:io) {sockets.first}
subject {described_class.new(sockets.last)}
it_should_behave_like Async::IO
+ describe '#drain_write_buffer' do
+ include_context Async::RSpec::Reactor
+ let(:output) {described_class.new(sockets.last)}
+ subject {described_class.new(sockets.first)}
+
+ let(:buffer_size) {1024*6}
+
+ it "can interleave calls to flush" do
+ tasks = 2.times.map do |i|
+ reactor.async do
+ buffer = i.to_s * buffer_size
+ 128.times do
+ output.write(buffer)
+ output.flush
+ end
+ end
+ end
+
+ reactor.async do
+ tasks.each(&:wait)
+ output.close
+ end
+
+ Async::Task.current.sleep(1)
+
+ while buffer = subject.read(buffer_size)
+ expect(buffer).to be == (buffer[0] * buffer_size)
+ end
+ end
+ end
+
describe '#close_read' do
subject {described_class.new(sockets.last)}
it "can close the reading end of the stream" do
expect(subject.io).to receive(:close_read).and_call_original