Sha256: a318953122b2424d5286e96cd12fb3129ba0d4770d5e208360b57e3760c092e3

Contents?: true

Size: 849 Bytes

Versions: 1

Compression:

Stored size: 849 Bytes

Contents

require 'test_helper'

describe Outpost::Scouts::Tcp do
  it "should set the time of ping in milliseconds" do
    cls = Class.new do
      def initialize(host, port, timeout)
      end

      def duration
        0.01
      end

      def ping? 
        true
      end
    end

    config = config_stub(:port => 9595, :pinger => cls)
    subject = Outpost::Scouts::Tcp.new "test", config
    subject.execute

    assert subject.response_time.to_i < 100
  end

  it "should set the time to nil when it fails" do
    #nothing uses this port by deafult
    config = config_stub(:port => 16)
    subject = Outpost::Scouts::Tcp.new "test", config
    subject.execute

    assert subject.response_time.nil?
  end

  private

  def config_stub(options={})
    options = {:host => 'localhost'}.merge options

    build_stub(:options => options)
  end  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
outpost-0.2.5 test/outpost/scouts/tcp_test.rb