Sha256: 7b4e262ee803c8151528597c9ad45e3abc3ac9f2c9145e028c6505c3fc83706e
Contents?: true
Size: 1020 Bytes
Versions: 1
Compression:
Stored size: 1020 Bytes
Contents
require 'test_helper' describe Outpost::Scouts::Ping do class PingStub def initialize(ping_successful, duration=nil) @ping_successful = ping_successful @duration = duration end def ping(*args); @ping_successful; end def duration; @duration; end end it "should set the time of ping in milliseconds" do config = config_stub(:pinger => PingStub.new(true, 0.225)) subject = Outpost::Scouts::Ping.new "test", config subject.execute assert_equal 225, subject.response_time end it "should set the time to nil when it fails" do config = config_stub(:pinger => PingStub.new(false)) subject = Outpost::Scouts::Ping.new "test", config subject.execute refute subject.response_time end private def config_stub(options={}) options = {:host => 'localhost'}.merge options build_stub(:options => options) end def pinger_stub(should_respond, time=nil) build_stub(:ping => should_respond, :duration => time) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
outpost-0.2.0 | test/outpost/scouts/ping_test.rb |