Skip to content

Commit

Permalink
Add stream spec.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Mar 17, 2020
1 parent a45a548 commit b780d1c
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions spec/async/io/unix_endpoint_spec.rb
Expand Up @@ -21,6 +21,7 @@
# THE SOFTWARE.

require 'async/io/unix_endpoint'
require 'async/io/stream'

RSpec.describe Async::IO::UNIXEndpoint do
include_context Async::RSpec::Reactor
Expand Down Expand Up @@ -77,4 +78,29 @@

server_task.stop
end

context "using buffered stream" do
it "can use stream to read and write data" do
server_task = reactor.async do |task|
subject.accept do |peer|
stream = Async::IO::Stream.new(peer)
stream.write(stream.read)
stream.close
end
end

reactor.async do
subject.connect do |client|
stream = Async::IO::Stream.new(client)

stream.write(data)
stream.close_write

expect(stream.read).to be == data
end
end.wait

server_task.stop
end
end
end

0 comments on commit b780d1c

Please sign in to comment.