Sha256: b142b57e22f3afbdaf4b1abb61930a03f0357fe088f2b332c757de6b529e6444

Contents?: true

Size: 1.68 KB

Versions: 21

Compression:

Stored size: 1.68 KB

Contents

# frozen_string_literal: true

require 'finapps_core/error'

RSpec.describe FinAppsCore::REST::Configuration do
  describe '#new' do
    context 'for invalid timeout configuration' do
      subject { FinAppsCore::REST::Configuration.new(timeout: 'whatever') }
      expected_error = FinAppsCore::InvalidArgumentsError
      it { expect { subject }.to raise_error(expected_error, 'Invalid argument. {timeout: whatever}') }
    end

    context 'for missing timeout configuration' do
      subject { FinAppsCore::REST::Configuration.new(timeout: nil) }
      it 'should have a default timeout value' do
        expect(subject.timeout).to eq(FinAppsCore::REST::Defaults::DEFAULTS[:timeout])
      end
    end

    context 'for invalid host configuration' do
      subject { FinAppsCore::REST::Configuration.new(host: 'whatever') }
      expected_error = FinAppsCore::InvalidArgumentsError
      it { expect { subject }.to raise_error(expected_error, 'Invalid argument. {host: whatever}') }
    end

    context 'for missing host configuration' do
      subject { FinAppsCore::REST::Configuration.new(host: nil) }
      it 'should have a default host value' do
        expect(subject.host).to eq(FinAppsCore::REST::Defaults::DEFAULTS[:host])
      end
    end
  end

  describe '#valid_user_credentials??' do
    context 'when user credentials were not set' do
      subject { FinAppsCore::REST::Configuration.new(host: nil) }
      it { expect(subject.valid_user_credentials?).to eq(false) }
    end
    context 'when user credentials were set' do
      subject { FinAppsCore::REST::Configuration.new(user_identifier: 1, user_token: 2) }
      it { expect(subject.valid_user_credentials?).to eq(true) }
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
finapps_core-5.0.7 spec/rest/configuration_spec.rb
finapps_core-5.0.6 spec/rest/configuration_spec.rb
finapps_core-5.0.5 spec/rest/configuration_spec.rb
finapps_core-5.0.4 spec/rest/configuration_spec.rb
finapps_core-5.0.3 spec/rest/configuration_spec.rb
finapps_core-5.0.2 spec/rest/configuration_spec.rb
finapps_core-5.0.1 spec/rest/configuration_spec.rb
finapps_core-5.0.0 spec/rest/configuration_spec.rb
finapps_core-4.0.7 spec/rest/configuration_spec.rb
finapps_core-4.0.6 spec/rest/configuration_spec.rb
finapps_core-4.0.5 spec/rest/configuration_spec.rb
finapps_core-4.0.4 spec/rest/configuration_spec.rb
finapps_core-4.0.3 spec/rest/configuration_spec.rb
finapps_core-4.0.2 spec/rest/configuration_spec.rb
finapps_core-4.0.0 spec/rest/configuration_spec.rb
finapps_core-3.0.6 spec/rest/configuration_spec.rb
finapps_core-3.0.5 spec/rest/configuration_spec.rb
finapps_core-3.0.3 spec/rest/configuration_spec.rb
finapps_core-3.0.1 spec/rest/configuration_spec.rb
finapps_core-2.1.2 spec/rest/configuration_spec.rb