Skip to content

Commit

Permalink
Merge pull request #246 from gocardless/more_pseudo_iban_specs
Browse files Browse the repository at this point in the history
Improve specs related to Pseudo IBAN validation
  • Loading branch information
rrundzansgc committed Oct 3, 2023
2 parents c052921 + f2f44e9 commit f0d8f87
Showing 1 changed file with 71 additions and 1 deletion.
72 changes: 71 additions & 1 deletion spec/ibandit/iban_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1662,10 +1662,68 @@
end
end

describe "#valid?" do
describe "Pseudo IBAN #valid?" do
let(:country_code) { "CA" }
let(:arg) do
{
country_code: country_code,
bank_code: "0036",
branch_code: "00063",
account_number: "1234567",
}
end

describe "validations called" do
after { iban.valid? }

specify { expect(iban).to receive(:valid_pseudo_iban?).at_least(1) }
specify { expect(iban).to receive(:valid_pseudo_iban_check_digits?).at_least(1) }
specify { expect(iban).to receive(:valid_country_code?).at_least(1) }
specify { expect(iban).to receive(:valid_bank_code_length?).at_least(1) }
specify { expect(iban).to receive(:valid_branch_code_length?).at_least(1) }
specify { expect(iban).to receive(:valid_account_number_length?).at_least(1) }
specify { expect(iban).to receive(:valid_bank_code_format?).at_least(1) }
specify { expect(iban).to receive(:valid_branch_code_format?).at_least(1) }
specify { expect(iban).to receive(:valid_account_number_format?).at_least(1) }
specify { expect(iban).to receive(:passes_country_specific_checks?).at_least(1) }

context "SE" do
let(:country_code) { "SE" }

specify { expect(iban).to receive(:valid_swedish_details?).at_least(1) }
end

context "AU" do
let(:country_code) { "AU" }

specify { expect(iban).to receive(:valid_australian_details?).at_least(1) }
end

context "NZ" do
let(:country_code) { "NZ" }

specify { expect(iban).to receive(:valid_nz_details?).at_least(1) }
end

context "CA" do
let(:country_code) { "CA" }

specify { expect(iban).to receive(:valid_ca_details?).at_least(1) }
end

context "US" do
let(:country_code) { "US" }

specify { expect(iban).to receive(:bank_code_passes_checksum_test?).at_least(1) }
end
end
end

describe "IBAN #valid?" do
describe "validations called" do
after { iban.valid? }

specify { expect(iban).to receive(:valid_iban?).at_least(1) }
specify { expect(iban).to receive(:valid_country_code?).at_least(1) }
specify { expect(iban).to receive(:valid_characters?).at_least(1) }
specify { expect(iban).to receive(:valid_check_digits?).at_least(1) }
Expand Down Expand Up @@ -1697,6 +1755,18 @@
it "runs country specific checks" do
expect(iban).to receive(:passes_country_specific_checks?).at_least(1)
end

context "DE" do
let(:arg) do
{
country_code: "DE",
bank_code: "20000000",
account_number: "7955791111",
}
end

specify { expect(iban).to receive(:supports_iban_determination?).at_least(1) }
end
end

RSpec.shared_examples "a country's IBAN" do |country_code|
Expand Down

0 comments on commit f0d8f87

Please sign in to comment.