Sha256: d577980fc2da8a10c3bc4d125beef009240600c97ab8aa525d5866d32e664ded
Contents?: true
Size: 1.63 KB
Versions: 1
Compression:
Stored size: 1.63 KB
Contents
require 'gorgon/ping_service' describe "PingService" do describe "#ping_listeners" do let(:configuration){ {:connection => {:host => "host"}, :originator_log_file => "file.log"}} let(:protocol) { stub("OriginatorProtocol", :connect => nil, :ping => nil, :receive_payloads => nil, :disconnect => nil, :ping_listeners => nil)} let(:logger){ stub("Originator Logger", :log => nil, :log_message => nil)} before do $stdout.stub!(:write) PingService.any_instance.stub(:load_configuration_from_file).and_return configuration EventMachine.stub!(:run).and_yield EM.stub!(:add_timer).and_yield OriginatorLogger.stub!(:new).and_return logger end it "connnects and calls OriginatorProtocol#ping_listeners" do OriginatorProtocol.should_receive(:new).once.ordered.and_return(protocol) protocol.should_receive(:connect).once.ordered.with({:host => "host"}, anything) protocol.should_receive(:ping_listeners).once.ordered PingService.new.ping_listeners end context "after sending ping messages" do before do OriginatorProtocol.stub!(:new).and_return(protocol) @service = PingService.new end it "adds an Event machine timer" do EM.should_receive(:add_timer).and_yield @service.ping_listeners end it "receives a ping_response message" do payload = {:type => "ping_response", :hostname => "host", :version => "1.1.1"} protocol.should_receive(:receive_payloads).and_yield Yajl::Encoder.encode(payload) @service.ping_listeners end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gorgon-0.2.0 | spec/ping_service_spec.rb |