Sha256: 16849103d035522a4d8d646b487a05fc7ac1d1da041e9e208ac3ed8fbf5beace

Contents?: true

Size: 1.69 KB

Versions: 7

Compression:

Stored size: 1.69 KB

Contents

# frozen_string_literal: true
require 'spec_helper'

describe Msgr::Client do
  subject { described_class.new config }
  let(:config) { {} }

  describe '#uri' do
    subject { super().uri.to_s }

    context 'with default config' do
      it 'uses the default config' do
        is_expected.to eq 'amqp://127.0.0.1'
      end
    end

    context 'with overwritten URI' do
      context 'without vhost' do
        let(:config) { {uri: 'amqp://rabbit'} }

        it 'does not specify a vhost' do
          is_expected.to eq 'amqp://rabbit'
        end
      end

      context 'with empty vhost' do
        let(:config) { {uri: 'amqp://rabbit/'} }

        it 'does not specify a vhost' do
          is_expected.to eq 'amqp://rabbit'
        end
      end

      context 'with explicit vhost' do
        let(:config) { {uri: 'amqp://rabbit/some_vhost'} }

        # This behavior is due to legacy parsing in Msgr's config.
        # We interpret the entire path (incl. the leading slash)
        # as vhost. As per AMQP rules, this means the leading slash
        # is part of the vhost, which means it has to be URL encoded.
        # This will likely change with the next major release.
        it 'uses the entire path as vhost' do
          is_expected.to eq 'amqp://rabbit/%2Fsome_vhost'
        end
      end
    end

    context 'with URI and vhost' do
      let(:config) { {uri: 'amqp://rabbit/some_vhost', vhost: 'real_vhost'} }

      # This is currently the only way to specify a vhost without
      # leading slash (as a vhost in the :uri config would have
      # an extra URL encoded leading slash).
      it 'uses the explicit vhost' do
        is_expected.to eq 'amqp://rabbit/real_vhost'
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
msgr-0.15.2.1.b157 spec/msgr/msgr/client_spec.rb
msgr-0.15.2.1.b156 spec/msgr/msgr/client_spec.rb
msgr-0.15.2.1.b155 spec/msgr/msgr/client_spec.rb
msgr-0.15.2.1.b154 spec/msgr/msgr/client_spec.rb
msgr-0.15.2.1.b152 spec/msgr/msgr/client_spec.rb
msgr-0.15.1.1.b151 spec/msgr/msgr/client_spec.rb
msgr-0.15.2 spec/msgr/msgr/client_spec.rb