Sha256: d48481a16fcce5a5eabdffdd537ef7a506499125dc04632b0b408449f42a06ca

Contents?: true

Size: 1.69 KB

Versions: 91

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

91 entries across 91 versions & 1 rubygems

Version Path
msgr-1.2.0 spec/msgr/msgr/client_spec.rb
msgr-1.1.0.1.b306 spec/msgr/msgr/client_spec.rb
msgr-1.1.0.1.b305 spec/msgr/msgr/client_spec.rb
msgr-1.1.0.1.b302 spec/msgr/msgr/client_spec.rb
msgr-1.1.0.1.b301 spec/msgr/msgr/client_spec.rb
msgr-1.1.0.1.b300 spec/msgr/msgr/client_spec.rb
msgr-1.1.0.1.b297 spec/msgr/msgr/client_spec.rb
msgr-1.1.0.1.b296 spec/msgr/msgr/client_spec.rb
msgr-1.1.0.1.b295 spec/msgr/msgr/client_spec.rb
msgr-1.1.0.1.b292 spec/msgr/msgr/client_spec.rb
msgr-1.1.0.1.b291 spec/msgr/msgr/client_spec.rb
msgr-1.1.0.1.b288 spec/msgr/msgr/client_spec.rb
msgr-1.1.0.1.b285 spec/msgr/msgr/client_spec.rb
msgr-1.1.0.1.b263 spec/msgr/msgr/client_spec.rb
msgr-1.1.0.1.b249 spec/msgr/msgr/client_spec.rb
msgr-1.1.0.1.b248 spec/msgr/msgr/client_spec.rb
msgr-1.1.0.1.b244 spec/msgr/msgr/client_spec.rb
msgr-1.1.0.1.b241 spec/msgr/msgr/client_spec.rb
msgr-1.1.0.1.b240 spec/msgr/msgr/client_spec.rb
msgr-1.1.0.1.b239 spec/msgr/msgr/client_spec.rb