Sha256: 44736e716e3d905f4bca89f7fdd64ccd266c281f484b9c0a9af2c762d274c0dd
Contents?: true
Size: 1.45 KB
Versions: 1
Compression:
Stored size: 1.45 KB
Contents
require 'spec_helper' require 'basquiat/adapters/rabbitmq_adapter' describe Basquiat::Adapters::RabbitMq::Connection do subject(:connection) { Basquiat::Adapters::RabbitMq::Connection } let(:servers) do [{ host: ENV.fetch('BASQUIAT_RABBITMQ_1_PORT_5672_TCP_ADDR') { 'localhost' }, port: ENV.fetch('BASQUIAT_RABBITMQ_1_PORT_5672_TCP_PORT') { 5672 } }] end before(:each) do Basquiat.configure { |c| c.logger = Logger.new('log/basquiat.log') } end it '#connected?' do conn = connection.new(servers: servers) expect(conn.connected?).to be_falsey conn.start expect(conn.connected?).to_not be_truthy conn.disconnect end context 'failover' do let(:failover) do { default_timeout: 0.2, max_retries: 2, threaded: false } end before(:each) { servers.unshift(host: 'localhost', port: 1234) } it 'tries a reconnection after a few seconds' do conn = connection.new(servers: [host: 'localhost', port: 1234], failover: { default_timeout: 0.2, max_retries: 1 }) expect { conn.start }.to raise_error(Bunny::TCPConnectionFailed) conn.close end it 'uses another server after all retries on a single one' do conn = connection.new(servers: servers, failover: failover) expect { conn.start }.to_not raise_error expect(conn.current_server_uri).to match "#{ENV.fetch('BASQUIAT_RABBITMQ_1_PORT_5672_TCP_PORT') { 5672 }}" conn.close end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
basquiat-1.2.0 | spec/lib/adapters/rabbitmq/connection_spec.rb |