Sha256: d48b7bbd3cf8195a9b68881c43aa4a563b136c170afc332c9d7c2e6f97067ca2

Contents?: true

Size: 839 Bytes

Versions: 5

Compression:

Stored size: 839 Bytes

Contents

require 'rubygems'
require 'bundler/setup'
require 'celluloid/io'
require 'celluloid/rspec'

class ExampleActor
  include Celluloid::IO

  def wrap
    yield
  end
end

EXAMPLE_PORT = 10000 + rand(10000)

def example_addr; '127.0.0.1'; end
def example_port; EXAMPLE_PORT; end

def within_io_actor(&block)
  actor = ExampleActor.new
  actor.wrap(&block)
ensure
  actor.terminate
end

def with_tcp_server
  server = Celluloid::IO::TCPServer.new(example_addr, example_port)
  begin
    yield server
  ensure
    server.close
  end
end

def with_connected_sockets
  with_tcp_server do |server|
    # FIXME: client isn't actually a Celluloid::IO::TCPSocket yet
    client = ::TCPSocket.new(example_addr, example_port)
    peer = server.accept

    begin
      yield peer, client
    ensure
      client.close
      peer.close
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

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