Sha256: be4f74e70cc8a5a16765545d2a72936ffc3f742a4cfa1cea0fa22ac73c0ec8cc
Contents?: true
Size: 1.33 KB
Versions: 12
Compression:
Stored size: 1.33 KB
Contents
require 'unit_spec_helper' describe Rpush::Daemon::Dispatcher::Tcp do let(:app) { double } let(:delivery) { double(perform: nil) } let(:delivery_class) { double(new: delivery) } let(:notification) { double } let(:batch) { double } let(:connection) { double(Rpush::Daemon::TcpConnection, connect: nil) } let(:host) { 'localhost' } let(:port) { 1234 } let(:host_proc) { proc { [host, port] } } let(:queue_payload) { Rpush::Daemon::QueuePayload.new(batch, notification) } let(:dispatcher) { Rpush::Daemon::Dispatcher::Tcp.new(app, delivery_class, host: host_proc) } before { Rpush::Daemon::TcpConnection.stub(new: connection) } describe 'dispatch' do it 'lazily connects the socket' do Rpush::Daemon::TcpConnection.should_receive(:new).with(app, host, port).and_return(connection) connection.should_receive(:connect) dispatcher.dispatch(queue_payload) end it 'delivers the notification' do delivery_class.should_receive(:new).with(app, connection, notification, batch).and_return(delivery) delivery.should_receive(:perform) dispatcher.dispatch(queue_payload) end end describe 'cleanup' do it 'closes the connection' do dispatcher.dispatch(queue_payload) # lazily initialize connection connection.should_receive(:close) dispatcher.cleanup end end end
Version data entries
12 entries across 12 versions & 1 rubygems