Sha256: ff2715060644c4b5be1d5d15dd6b98a10bf4ce92dd65a0db1dc43c011618181a

Contents?: true

Size: 1.68 KB

Versions: 19

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

19 entries across 19 versions & 1 rubygems

Version Path
finapps_core-2.0.20 spec/rest/configuration_spec.rb
finapps_core-2.0.19 spec/rest/configuration_spec.rb
finapps_core-2.0.18 spec/rest/configuration_spec.rb
finapps_core-2.0.17 spec/rest/configuration_spec.rb
finapps_core-2.0.16 spec/rest/configuration_spec.rb
finapps_core-2.0.15 spec/rest/configuration_spec.rb
finapps_core-2.0.14 spec/rest/configuration_spec.rb
finapps_core-2.0.13 spec/rest/configuration_spec.rb
finapps_core-2.0.12 spec/rest/configuration_spec.rb
finapps_core-2.0.11 spec/rest/configuration_spec.rb
finapps_core-2.0.10 spec/rest/configuration_spec.rb
finapps_core-2.0.9 spec/rest/configuration_spec.rb
finapps_core-2.0.8 spec/rest/configuration_spec.rb
finapps_core-2.0.7 spec/rest/configuration_spec.rb
finapps_core-2.0.6 spec/rest/configuration_spec.rb
finapps_core-2.0.5 spec/rest/configuration_spec.rb
finapps_core-2.0.4 spec/rest/configuration_spec.rb
finapps_core-2.0.3 spec/rest/configuration_spec.rb
finapps_core-2.0.2 spec/rest/configuration_spec.rb