Sha256: 240bac11e4077157e1d7ed095a7862289904a38929743f61fb84d47b0017b98e
Contents?: true
Size: 1.64 KB
Versions: 3
Compression:
Stored size: 1.64 KB
Contents
require 'spec_helper' require 'spec_helper' class Handler < Raktr::Connection attr_reader :received_data attr_reader :error def initialize( options = {} ) @options = options end def on_close( error ) @error = error if @options[:on_error] @options[:on_error].call error end @raktr.stop end def on_read( data ) (@received_data ||= '' ) << data return if !@options[:on_read] @options[:on_read].call data end end describe Raktr::Connection do before :all do @host, @port = Servers.start( :echo ) if Raktr.supports_unix_sockets? _, port = Servers.start( :echo_unix ) @unix_socket = port_to_socket( port ) end end before :each do @accept_q = Queue.new @accepted = nil end let(:unix_socket) { unix_connect( @unix_socket ) } let(:unix_server_socket) { unix_server( port_to_socket( Servers.available_port ) ) } let(:echo_client) { tcp_socket } let(:echo_client_handler) { EchoClient.new } let(:peer_client_socket) { tcp_connect( host, port ) } let(:peer_server_socket) do s = tcp_server( host, port ) Thread.new do begin @accept_q << s.accept rescue => e ap e end end s end let(:accepted) { @accepted ||= @accept_q.pop } let(:client_socket) { tcp_socket } let(:server_socket) { tcp_server( host, port ) } let(:connection) { Handler.new } let(:server_handler) { proc { Handler.new } } it_should_behave_like 'Raktr::Connection' end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
raktr-0.0.3 | spec/raktr/connection_spec.rb |
raktr-0.0.2 | spec/raktr/connection_spec.rb |
raktr-0.0.1 | spec/raktr/connection_spec.rb |