Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve specs related to Pseudo IBAN validation #246

Merged
merged 1 commit into from
Oct 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not exactly a fan of testing internal methods but if this is existing and we find it valuable then its fine

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