From f2f44e94e20ce529d7ce2d2f3110ab86dad5b594 Mon Sep 17 00:00:00 2001 From: rrundzans Date: Tue, 3 Oct 2023 11:21:24 +0300 Subject: [PATCH] Improve specs related to Pseudo IBAN validation: For IBANs it is specified which validation methods should be called during validation (see "validations called" example group). Do the same thing for Pseudo IBANs, and also describe expected country specific validations. --- spec/ibandit/iban_spec.rb | 72 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-) diff --git a/spec/ibandit/iban_spec.rb b/spec/ibandit/iban_spec.rb index 6760dd8..3e4d912 100755 --- a/spec/ibandit/iban_spec.rb +++ b/spec/ibandit/iban_spec.rb @@ -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) } @@ -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|