Sha256: 1c7a53e10c810bc33ca1649100ddade26cc0af94bcedbc7f89b218dc8c21d388

Contents?: true

Size: 1.34 KB

Versions: 5

Compression:

Stored size: 1.34 KB

Contents

require 'spec_helper'

describe Celluloid::IO::TCPServer do
  describe "#accept" do
    let(:payload) { 'ohai' }

    context "inside Celluloid::IO" do
      it "should be evented" do
        with_tcp_server do |subject|
          within_io_actor { subject.evented? }.should be_true
        end
      end

      it "accepts a connection and returns a Celluloid::IO::TCPSocket" do
        with_tcp_server do |subject|
          thread = Thread.new { TCPSocket.new(example_addr, example_port) }
          peer = within_io_actor { subject.accept }
          peer.should be_a Celluloid::IO::TCPSocket

          client = thread.value
          client.write payload
          peer.read(payload.size).should eq payload
        end
      end

      context "elsewhere in Ruby" do
        it "should be blocking" do
          with_tcp_server do |subject|
            subject.should_not be_evented
          end
        end

        it "accepts a connection and returns a Celluloid::IO::TCPSocket" do
          with_tcp_server do |subject|
            thread = Thread.new { TCPSocket.new(example_addr, example_port) }
            peer   = subject.accept
            peer.should be_a Celluloid::IO::TCPSocket

            client = thread.value
            client.write payload
            peer.read(payload.size).should eq payload
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
celluloid-io-0.12.1 spec/celluloid/io/tcp_server_spec.rb
celluloid-io-0.12.0 spec/celluloid/io/tcp_server_spec.rb
celluloid-io-0.11.0 spec/celluloid/io/tcp_server_spec.rb
celluloid-io-0.10.0 spec/celluloid/io/tcp_server_spec.rb
celluloid-io-0.9.0 spec/celluloid/io/tcp_server_spec.rb