Sha256: 1e07cb968d4802ba7301c289fae7c0233faefd3d65a27691db2903fb2f2b9d67
Contents?: true
Size: 1.76 KB
Versions: 3
Compression:
Stored size: 1.76 KB
Contents
require 'rubygems' require 'bundler/setup' require 'celluloid/io' require 'celluloid/rspec' require 'coveralls' Coveralls.wear! logfile = File.open(File.expand_path("../../log/test.log", __FILE__), 'a') Celluloid.logger = Logger.new(logfile) # FIXME: Hax until test termination can be cleaned up module Celluloid class << self def shutdown; end # hax: noop! end end class ExampleActor include Celluloid::IO def wrap yield end end EXAMPLE_PORT = 12345 def example_addr; '127.0.0.1'; end def example_port; EXAMPLE_PORT; end def example_unix_sock; '/tmp/cell_sock'; end def example_ssl_port; EXAMPLE_PORT + 1; end def fixture_dir; Pathname.new File.expand_path("../fixtures", __FILE__); end def within_io_actor(&block) actor = ExampleActor.new actor.wrap(&block) ensure actor.terminate if actor.alive? end def with_tcp_server server = Celluloid::IO::TCPServer.new(example_addr, example_port) begin yield server ensure server.close end end def with_unix_server server = Celluloid::IO::UNIXServer.open(example_unix_sock) begin yield server ensure server.close File.delete(example_unix_sock) 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 begin client.close peer.close rescue end end end end def with_connected_unix_sockets with_unix_server do |server| client = Celluloid::IO::UNIXSocket.new(example_unix_sock) peer = server.accept begin yield peer, client ensure begin client.close peer.close rescue end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
celluloid-io-0.13.1 | spec/spec_helper.rb |
celluloid-io-0.13.0 | spec/spec_helper.rb |
celluloid-io-0.13.0.pre2 | spec/spec_helper.rb |