Sha256: a405e3dba2e8e8a16b75044666839d604d2bdb92b426b254b8974eedf88be28e

Contents?: true

Size: 1.46 KB

Versions: 3

Compression:

Stored size: 1.46 KB

Contents

# encoding: utf-8
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__))

require 'spec_helper'
require 'server_discovery_helper'

describe 'AMQP::Failover::ServerDiscovery' do
  
  before(:each) do
    $called = []
    $start_count = 0
    @args = { :host => 'localhost', :port => 9999 }
    @retry_interval = 0.01
  end
  
  after(:all) do
    $called = nil
    $start_count = nil
  end
  
  it "should initialize" do
    EM.run {
      EM.start_server('127.0.0.1', 9999)
      @mon = ServerDiscoveryHelper.monitor(@args, @retry_interval) do
        $called << :done_block
        EM.stop_event_loop
      end
    }
    $start_count.should == 1
    $called.should have(5).items
    $called.uniq.should have(5).items
    $called.should include(:start_monitoring)
    $called.should include(:initialize)
    $called.should include(:connection_completed)
    $called.should include(:close_connection)
    $called.should include(:done_block)
  end
  
  it "should retry on error" do
    EM.run {
      @mon = ServerDiscoveryHelper.monitor(@args, @retry_interval) do
        $called << :done_block
        EM.stop_event_loop
      end
    }
    $start_count.should >= 3
    $called.should have($start_count + 4).items
    $called.uniq.should have(5).items
    $called.should include(:start_monitoring)
    $called.should include(:initialize)
    $called.should include(:connection_completed)
    $called.should include(:close_connection)
    $called.should include(:done_block)
  end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
amqp-failover-0.0.3 spec/unit/amqp/failover/server_discovery_spec.rb
amqp-failover-0.0.2 spec/unit/amqp/failover/server_discovery_spec.rb
amqp-failover-0.0.1 spec/unit/amqp/failover/server_discovery_spec.rb