Sha256: b14313d136fd0bee530f038e4ba33e22505074b2b4b5d5212a6c97f668bd9669

Contents?: true

Size: 864 Bytes

Versions: 6

Compression:

Stored size: 864 Bytes

Contents

# frozen_string_literal: true

require 'spec_helper'
require 'fortnox/api/types'

describe Fortnox::API::Types::CountryCode do
  context 'with nil' do
    subject { described_class[nil] }

    it { is_expected.to be_nil }
  end

  context 'with empty string' do
    subject { described_class[''] }

    it { is_expected.to eq('') }
  end

  context 'with valid input' do
    it 'accepts country codes' do
      expect(described_class['NO']).to eq 'NO'
    end
  end

  context 'with invalid input' do
    describe 'valid country name' do
      it do
        expect do
          described_class['Norway']
        end.to raise_error(Dry::Types::ConstraintError)
      end
    end

    describe 'invalid country code' do
      it do
        expect do
          described_class['XX']
        end.to raise_error(Dry::Types::ConstraintError)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
fortnox-api-0.8.2 spec/fortnox/api/types/country_code_spec.rb
fortnox-api-0.8.1 spec/fortnox/api/types/country_code_spec.rb
fortnox-api-0.9.0 spec/fortnox/api/types/country_code_spec.rb
fortnox-api-0.8.0 spec/fortnox/api/types/country_code_spec.rb
fortnox-api-0.7.2 spec/fortnox/api/types/country_code_spec.rb
fortnox-api-0.7.1 spec/fortnox/api/types/country_code_spec.rb