Sha256: 84eac3e3f1b4a63ad7a322922eaffb91fa829c3459abc200589e15ad15647d98

Contents?: true

Size: 1.49 KB

Versions: 32

Compression:

Stored size: 1.49 KB

Contents

# frozen_string_literal: true

require "spec_helper"

describe Ibandit::IBANSplitter do
  subject(:split) { described_class.split(iban_code) }

  context "with a valid IBAN" do
    let(:iban_code) { "GB82WEST12345698765432" }

    its([:country_code]) { is_expected.to eq("GB") }
    its([:check_digits]) { is_expected.to eq("82") }
    its([:bank_code]) { is_expected.to eq("WEST") }
    its([:branch_code]) { is_expected.to eq("123456") }
    its([:account_number]) { is_expected.to eq("98765432") }
  end

  context "with nil" do
    let(:iban_code) { nil }

    its([:country_code]) { is_expected.to eq(nil) }
    its([:check_digits]) { is_expected.to eq(nil) }
    its([:bank_code]) { is_expected.to eq(nil) }
    its([:branch_code]) { is_expected.to eq(nil) }
    its([:account_number]) { is_expected.to eq(nil) }
  end

  context "with an empty string" do
    let(:iban_code) { "" }

    its([:country_code]) { is_expected.to eq(nil) }
    its([:check_digits]) { is_expected.to eq(nil) }
    its([:bank_code]) { is_expected.to eq(nil) }
    its([:branch_code]) { is_expected.to eq(nil) }
    its([:account_number]) { is_expected.to eq(nil) }
  end

  context "with an invalid length IBAN" do
    let(:iban_code) { "MC9320052222100112233M445" }

    its([:country_code]) { is_expected.to eq("MC") }
    its([:check_digits]) { is_expected.to eq(nil) }
    its([:bank_code]) { is_expected.to eq(nil) }
    its([:branch_code]) { is_expected.to eq(nil) }
    its([:account_number]) { is_expected.to eq(nil) }
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
ibandit-1.21.0 spec/ibandit/iban_splitter_spec.rb
ibandit-1.20.0 spec/ibandit/iban_splitter_spec.rb
ibandit-1.19.0 spec/ibandit/iban_splitter_spec.rb
ibandit-1.18.0 spec/ibandit/iban_splitter_spec.rb
ibandit-1.17.0 spec/ibandit/iban_splitter_spec.rb
ibandit-1.16.0 spec/ibandit/iban_splitter_spec.rb
ibandit-1.15.0 spec/ibandit/iban_splitter_spec.rb
ibandit-1.14.0 spec/ibandit/iban_splitter_spec.rb
ibandit-1.13.0 spec/ibandit/iban_splitter_spec.rb
ibandit-1.12.0 spec/ibandit/iban_splitter_spec.rb
ibandit-1.11.0 spec/ibandit/iban_splitter_spec.rb
ibandit-1.10.0 spec/ibandit/iban_splitter_spec.rb
ibandit-1.9.0 spec/ibandit/iban_splitter_spec.rb
ibandit-1.8.1 spec/ibandit/iban_splitter_spec.rb
ibandit-1.8.0 spec/ibandit/iban_splitter_spec.rb
ibandit-1.7.1 spec/ibandit/iban_splitter_spec.rb
ibandit-1.7.0 spec/ibandit/iban_splitter_spec.rb
ibandit-1.6.1 spec/ibandit/iban_splitter_spec.rb
ibandit-1.6.0 spec/ibandit/iban_splitter_spec.rb
ibandit-1.5.0 spec/ibandit/iban_splitter_spec.rb