Sha256: d2b2b014fbb745ef3391d6621be3ed9a5eff9832a971c198b365280cebad7740

Contents?: true

Size: 1.72 KB

Versions: 4

Compression:

Stored size: 1.72 KB

Contents

require 'spec_helper'

describe Msgr::Connection do

  describe '#rebind' do
    let(:conn) { double }
    let(:routes) { Msgr::Routes.new }
    let(:connection) { Msgr::Connection.new conn, routes, dispatcher }

    context 'with URI' do
      it 'should pass URI options to bunny (I)' do
        expect(Bunny).to receive(:new)
                         .with(pass: 'guest', user: 'guest', ssl: false, host: 'localhost', vhost: '/')

        Msgr::Client.new uri: 'amqp://guest:guest@localhost/'
      end

      it 'should pass URI options to bunny (II)' do
        expect(Bunny).to receive(:new)
                         .with(pass: 'msgr', user: 'abc', ssl: true, host: 'bogus.example.org', vhost: '/rabbit')

        Msgr::Client.new uri: 'amqps://abc:msgr@bogus.example.org/rabbit'
      end
    end

    context 'with options' do
      it 'should pass options to bunny' do
        expect(Bunny).to receive(:new)
                         .with(pass: 'guest', user: 'guest', ssl: false, host: 'localhost', vhost: '/')

        Msgr::Client.new pass: 'guest', user: 'guest', ssl: false, host: 'localhost', vhost: '/'
      end
    end

    context 'with URI and options' do
      it 'should pass merged options to bunny' do
        expect(Bunny).to receive(:new)
                         .with(pass: 'msgr', user: 'abc', ssl: false, host: 'localhost', vhost: '/joghurt')

        Msgr::Client.new uri: 'ampq://abc@localhost', pass: 'msgr', vhost: '/joghurt'
      end

      it 'should pass prefer hash option' do
        expect(Bunny).to receive(:new)
                         .with(ssl: true, host: 'a.example.org', vhost: '/', user: 'guest')

        Msgr::Client.new uri: 'ampq://localhost', ssl: true, host: 'a.example.org'
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
msgr-0.2.1 spec/msgr/msgr/connection_spec.rb
msgr-0.2.0 spec/msgr/msgr/connection_spec.rb
msgr-0.1.1 spec/msgr/msgr/connection_spec.rb
msgr-0.1.0 spec/msgr/msgr/connection_spec.rb