Sha256: 9f1e426ce586f9080058237380c1123cae1e9daa885a027ea59512adb844f6f3

Contents?: true

Size: 1.61 KB

Versions: 18

Compression:

Stored size: 1.61 KB

Contents

require 'pact_broker/client/base_client'
module PactBroker
  module Client
    describe BaseClient do
      describe '#initialize' do
        let(:base_url) { 'http://pact_broker_base_url'}
        let(:username) { 'pact_repo_username'}
        let(:password) { 'pact_repo_password'}
        let(:client_options) do
          {
            basic_auth: {
              username: username,
              password: password
            }
          }
        end
        context 'with basic url' do
          it 'should set base url' do
            base_client = BaseClient.new(base_url: base_url)
            expect(base_client.base_url).to eq(base_url)
            expect(BaseClient.base_uri).to eq(base_url)
          end
        end

        context 'with client options' do
          subject { BaseClient.new(base_url: base_url, client_options: client_options) }
          it 'should set client options ' do
            expect(subject.client_options).to eq(client_options)
          end

          it 'should set httpparty basic auth when client options contains basic auth' do
            expect(BaseClient).to receive(:basic_auth).with(username, password)
            subject
          end
        end

        context 'without client options' do
          subject { BaseClient.new(base_url: base_url) }
          it 'should set client options to empty hash ' do
            expect(subject.client_options).to eq({})
          end

          it 'should not set httpparty basic auth' do
            expect(BaseClient).to_not receive(:basic_auth).with(username, password)
            subject
          end
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
pact_broker-client-1.13.1 spec/lib/pact_broker/client/base_client_spec.rb
pact_broker-client-1.13.0 spec/lib/pact_broker/client/base_client_spec.rb
pact_broker-client-1.12.0 spec/lib/pact_broker/client/base_client_spec.rb
pact_broker-client-1.11.0 spec/lib/pact_broker/client/base_client_spec.rb
pact_broker-client-1.10.0 spec/lib/pact_broker/client/base_client_spec.rb
pact_broker-client-1.9.0 spec/lib/pact_broker/client/base_client_spec.rb
pact_broker-client-1.8.0 spec/lib/pact_broker/client/base_client_spec.rb
pact_broker-client-1.7.0 spec/lib/pact_broker/client/base_client_spec.rb
pact_broker-client-1.6.0 spec/lib/pact_broker/client/base_client_spec.rb
pact_broker-client-1.5.0 spec/lib/pact_broker/client/base_client_spec.rb
pact_broker-client-1.4.0 spec/lib/pact_broker/client/base_client_spec.rb
pact_broker-client-1.3.0 spec/lib/pact_broker/client/base_client_spec.rb
pact_broker-client-1.2.0 spec/lib/pact_broker/client/base_client_spec.rb
pact_broker-client-1.1.0 spec/lib/pact_broker/client/base_client_spec.rb
pact_broker-client-1.0.3 spec/lib/pact_broker/client/base_client_spec.rb
pact_broker-client-1.0.2 spec/lib/pact_broker/client/base_client_spec.rb
pact_broker-client-1.0.1 spec/lib/pact_broker/client/base_client_spec.rb
pact_broker-client-1.0.0 spec/lib/pact_broker/client/base_client_spec.rb