ibandit 1.20.0 → 1.22.0

Sign up to get free protection for your applications and to get access to all the features.
data/data/structures.yml CHANGED
@@ -273,7 +273,7 @@ EE:
273
273
  :iban_example: EE382200221020145685
274
274
  :bban_example: '2200221020145685'
275
275
  :domestic_account_number_example: '221020145685'
276
- :bban_format: "\\d{2}\\d{2}\\d{11}\\d{1}"
276
+ :bban_format: "\\d{2}\\d{14}"
277
277
  :bank_code_format: "[1-9][0-9]"
278
278
  :account_number_format: "\\d{2}\\d{11}\\d{1}"
279
279
  :local_check_digit_position: 20
@@ -286,7 +286,7 @@ ES:
286
286
  :account_number_position: 13
287
287
  :account_number_length: 12
288
288
  :total_length: 24
289
- :national_id_length: 4
289
+ :national_id_length: 8
290
290
  :iban_example: ES9121000418450200051332
291
291
  :bban_example: '21000418450200051332'
292
292
  :domestic_account_number_example: 2100 0418 45 0200051332
@@ -841,8 +841,8 @@ PT:
841
841
  :domestic_account_number_example: 0002.0123.12345678901.54
842
842
  :bban_format: "\\d{4}\\d{4}\\d{11}\\d{2}"
843
843
  :bank_code_format: "\\d{4}"
844
- :account_number_format: "\\d{11}\\d{2}"
845
844
  :branch_code_format: "\\d{4}"
845
+ :account_number_format: "\\d{11}\\d{2}"
846
846
  :local_check_digit_position: 24
847
847
  :local_check_digit_length: 2
848
848
  RO:
@@ -1103,10 +1103,10 @@ ST:
1103
1103
  :account_number_length: 13
1104
1104
  :total_length: 25
1105
1105
  :national_id_length: 8
1106
- :iban_example: ST68000200010192194210112
1107
- :bban_example: '000200010192194210112'
1108
- :domestic_account_number_example: '01921942101.12'
1109
- :bban_format: "\\d{4}\\d{4}\\d{11}\\d{2}"
1106
+ :iban_example: ST23000100010051845310146
1107
+ :bban_example: '000100010051845310146'
1108
+ :domestic_account_number_example: '0051845310146'
1109
+ :bban_format: "\\d{8}\\d{11}\\d{2}"
1110
1110
  :bank_code_format: "\\d{4}"
1111
1111
  :branch_code_format: "\\d{4}"
1112
1112
  :account_number_format: "\\d{11}\\d{2}"
@@ -1137,9 +1137,9 @@ IQ:
1137
1137
  :iban_example: IQ98NBIQ850123456789012
1138
1138
  :bban_example: NBIQ850123456789012
1139
1139
  :domestic_account_number_example: '123456789012'
1140
- :bban_format: "[A-Z]{4}\\d{3}\\d{12}"
1141
1140
  :bank_code_format: "[A-Z]{4}"
1142
1141
  :branch_code_format: "\\d{3}"
1142
+ :bban_format: "[A-Z]{4}\\d{3}\\d{12}"
1143
1143
  :account_number_format: "\\d{12}"
1144
1144
  SV:
1145
1145
  :bank_code_position: 5
@@ -1357,6 +1357,12 @@ MN:
1357
1357
  :account_number_length: 12
1358
1358
  :total_length: 20
1359
1359
  :national_id_length: 4
1360
+ :iban_example: MN121234123456789123
1361
+ :bban_example: '1234123456789123'
1362
+ :domestic_account_number_example: 1234 5678 9123
1363
+ :bban_format: "\\d{4}\\d{12}"
1364
+ :bank_code_format: "\\d{4}"
1365
+ :account_number_format: "\\d{12}"
1360
1366
  DZ:
1361
1367
  :bank_code_position: 5
1362
1368
  :bank_code_length: 3
@@ -1472,13 +1478,90 @@ RU:
1472
1478
  :account_number_length: 15
1473
1479
  :total_length: 33
1474
1480
  :national_id_length: 14
1475
- :iban_example: RU1704452522540817810538091310419
1481
+ :iban_example: RU0304452522540817810538091310419
1476
1482
  :bban_example: 044525225 40817 810 5 3809 1310419
1477
1483
  :domestic_account_number_example: 40817 810 5 3809 1310419
1478
1484
  :bban_format: "\\d{9}\\d{5}[A-Z0-9]{15}"
1479
1485
  :bank_code_format: "\\d{9}"
1480
1486
  :branch_code_format: "\\d{5}"
1481
1487
  :account_number_format: "[A-Z0-9]{15}"
1488
+ SO:
1489
+ :bank_code_position: 5
1490
+ :bank_code_length: 4
1491
+ :branch_code_position: 9
1492
+ :branch_code_length: 3
1493
+ :account_number_position: 12
1494
+ :account_number_length: 12
1495
+ :total_length: 23
1496
+ :national_id_length: 7
1497
+ :iban_example: SO211000001001000100141
1498
+ :bban_example: '1000001001000100141'
1499
+ :domestic_account_number_example: '001000100141'
1500
+ :bban_format: "\\d{4}\\d{3}\\d{12}"
1501
+ :bank_code_format: "\\d{4}"
1502
+ :branch_code_format: "\\d{3}"
1503
+ :account_number_format: "\\d{12}"
1504
+ NI:
1505
+ :bank_code_position: 5
1506
+ :bank_code_length: 4
1507
+ :branch_code_position: 0
1508
+ :branch_code_length: 0
1509
+ :account_number_position: 9
1510
+ :account_number_length: 20
1511
+ :total_length: 28
1512
+ :national_id_length: 4
1513
+ :iban_example: NI45BAPR00000013000003558124
1514
+ :bban_example: BAPR00000013000003558124
1515
+ :domestic_account_number_example: '00000013000003558124'
1516
+ :bban_format: "[A-Z]{4}\\d{20}"
1517
+ :bank_code_format: "[A-Z]{4}"
1518
+ :account_number_format: "\\d{20}"
1519
+ FK:
1520
+ :bank_code_position: 5
1521
+ :bank_code_length: 2
1522
+ :branch_code_position: 0
1523
+ :branch_code_length: 0
1524
+ :account_number_position: 7
1525
+ :account_number_length: 12
1526
+ :total_length: 18
1527
+ :national_id_length: 2
1528
+ :iban_example: FK88SC123456789012
1529
+ :bban_example: SC123456789012
1530
+ :domestic_account_number_example: '123456789012'
1531
+ :bban_format: "[A-Z]{2}\\d{12}"
1532
+ :bank_code_format: "[A-Z]{2}"
1533
+ :account_number_format: "\\d{12}"
1534
+ OM:
1535
+ :bank_code_position: 5
1536
+ :bank_code_length: 3
1537
+ :branch_code_position: 0
1538
+ :branch_code_length: 0
1539
+ :account_number_position: 8
1540
+ :account_number_length: 16
1541
+ :total_length: 23
1542
+ :national_id_length: 3
1543
+ :iban_example: OM810180000001299123456
1544
+ :bban_example: '0180000001299123456'
1545
+ :domestic_account_number_example: '0000001299123456'
1546
+ :bban_format: "\\d{3}[A-Z0-9]{16}"
1547
+ :bank_code_format: "\\d{3}"
1548
+ :account_number_format: "[A-Z0-9]{16}"
1549
+ YE:
1550
+ :bank_code_position: 5
1551
+ :bank_code_length: 4
1552
+ :branch_code_position: 9
1553
+ :branch_code_length: 4
1554
+ :account_number_position: 13
1555
+ :account_number_length: 18
1556
+ :total_length: 30
1557
+ :national_id_length: 8
1558
+ :iban_example: YE15CBYE0001018861234567891234
1559
+ :bban_example: CBYE0001018861234567891234
1560
+ :domestic_account_number_example: '018861234567891234'
1561
+ :bban_format: "[A-Z]{4}\\d{4}[A-Z0-9]{18}"
1562
+ :bank_code_format: "[A-Z]{4}"
1563
+ :branch_code_format: "\\d{4}"
1564
+ :account_number_format: "[A-Z0-9]{18}"
1482
1565
  AU:
1483
1566
  :bank_code_length: 0
1484
1567
  :branch_code_length: 6
@@ -1493,13 +1576,16 @@ AU:
1493
1576
  :pseudo_iban_account_number_length: 10
1494
1577
  :national_id_length: 6
1495
1578
  CA:
1496
- :bank_code_length: 4
1579
+ :bank_code_length: !ruby/range
1580
+ begin: 3
1581
+ end: 4
1582
+ excl: false
1497
1583
  :branch_code_length: 5
1498
1584
  :account_number_length: !ruby/range
1499
1585
  begin: 7
1500
1586
  end: 12
1501
1587
  excl: false
1502
- :bank_code_format: "\\d{4}"
1588
+ :bank_code_format: "\\d{3,4}"
1503
1589
  :branch_code_format: 0{0,4}[1-9][0-9]{0,4}
1504
1590
  :account_number_format: "(?!0+\\z)\\d{7,12}"
1505
1591
  :national_id_length: 9
data/ibandit.gemspec CHANGED
@@ -27,13 +27,6 @@ Gem::Specification.new do |spec|
27
27
  spec.require_paths = ["lib"]
28
28
 
29
29
  spec.required_ruby_version = ">= 2.7.0"
30
- spec.add_development_dependency "gc_ruboconfig", "~> 4.3"
31
- spec.add_development_dependency "nokogiri", "~> 1.6"
32
- spec.add_development_dependency "pry", "~> 0.13"
33
- spec.add_development_dependency "pry-byebug", "~> 3.10"
34
- spec.add_development_dependency "rspec", "~> 3.12"
35
- spec.add_development_dependency "rspec-its", "~> 1.2"
36
- spec.add_development_dependency "sax-machine", "~> 1.3"
37
30
 
38
- spec.add_runtime_dependency "i18n"
31
+ spec.add_dependency "i18n"
39
32
  end
data/lib/ibandit/iban.rb CHANGED
@@ -158,14 +158,17 @@ module Ibandit
158
158
 
159
159
  def valid_bank_code_length?
160
160
  return unless valid_country_code?
161
- return true if structure[:bank_code_length]&.zero?
161
+ if structure[:bank_code_length].is_a?(Integer) && structure[:bank_code_length].zero?
162
+ return true
163
+ end
162
164
 
163
165
  if swift_bank_code.nil? || swift_bank_code.empty?
164
166
  @errors[:bank_code] = Ibandit.translate(:is_required)
165
167
  return false
166
168
  end
167
169
 
168
- return true if swift_bank_code.length == structure[:bank_code_length]
170
+ return true if valid_input_length?(structure[:bank_code_length],
171
+ swift_bank_code.length)
169
172
 
170
173
  @errors[:bank_code] =
171
174
  Ibandit.translate(:wrong_length, expected: structure[:bank_code_length])
@@ -176,16 +179,15 @@ module Ibandit
176
179
  return unless valid_country_code?
177
180
  return true if swift_branch_code.to_s.length == structure[:branch_code_length]
178
181
 
179
- if structure[:branch_code_length]&.zero?
180
- @errors[:branch_code] = Ibandit.translate(:not_used_in_country,
182
+ @errors[:branch_code] = if structure[:branch_code_length]&.zero?
183
+ Ibandit.translate(:not_used_in_country,
181
184
  country_code: country_code)
182
- elsif swift_branch_code.nil? || swift_branch_code.empty?
183
- @errors[:branch_code] = Ibandit.translate(:is_required)
184
- else
185
- @errors[:branch_code] =
186
- Ibandit.translate(:wrong_length,
187
- expected: structure[:branch_code_length])
188
- end
185
+ elsif swift_branch_code.nil? || swift_branch_code.empty?
186
+ Ibandit.translate(:is_required)
187
+ else
188
+ Ibandit.translate(:wrong_length,
189
+ expected: structure[:branch_code_length])
190
+ end
189
191
  false
190
192
  end
191
193
 
@@ -197,14 +199,8 @@ module Ibandit
197
199
  return false
198
200
  end
199
201
 
200
- case structure[:account_number_length]
201
- when Range
202
- if structure[:account_number_length].include?(swift_account_number.length)
203
- return true
204
- end
205
- else
206
- return true if swift_account_number.length == structure[:account_number_length]
207
- end
202
+ return true if valid_input_length?(structure[:account_number_length],
203
+ swift_account_number.length)
208
204
 
209
205
  @errors[:account_number] =
210
206
  Ibandit.translate(:wrong_length,
@@ -240,7 +236,9 @@ module Ibandit
240
236
 
241
237
  def valid_bank_code_format?
242
238
  return unless valid_bank_code_length?
243
- return true if structure[:bank_code_length]&.zero?
239
+ if structure[:bank_code_length].is_a?(Integer) && structure[:bank_code_length].zero?
240
+ return true
241
+ end
244
242
 
245
243
  if swift_bank_code&.match?(
246
244
  entire_string_regex(structure[:bank_code_format]),
@@ -391,7 +389,6 @@ module Ibandit
391
389
  valid_modulus_check_branch_code?
392
390
  end
393
391
 
394
- # rubocop:disable Metrics/AbcSize
395
392
  def bank_code_passes_checksum_test?
396
393
  return false unless swift_bank_code
397
394
  return false if swift_bank_code.length != 9
@@ -408,8 +405,6 @@ module Ibandit
408
405
 
409
406
  mod.zero?
410
407
  end
411
- # rubocop:enable Metrics/AbcSize
412
-
413
408
  ###################
414
409
  # Private methods #
415
410
  ###################
@@ -509,17 +504,26 @@ module Ibandit
509
504
  iban.to_s.gsub(/(.{4})/, '\1 ').strip
510
505
  end
511
506
 
507
+ def valid_input_length?(allowed_length, input_length)
508
+ case allowed_length
509
+ when Range
510
+ allowed_length.include?(input_length)
511
+ else
512
+ allowed_length == input_length
513
+ end
514
+ end
515
+
512
516
  def valid_modulus_check_bank_code?
513
517
  return true if Ibandit.modulus_checker.valid_bank_code?(self)
514
518
 
515
- @errors[:bank_code] = Ibandit.translate(:failed_modulus_check)
519
+ @errors[:bank_code] = Ibandit.translate(:bank_code_does_not_exist)
516
520
  false
517
521
  end
518
522
 
519
523
  def valid_modulus_check_branch_code?
520
524
  return true if Ibandit.modulus_checker.valid_branch_code?(self)
521
525
 
522
- @errors[:branch_code] = Ibandit.translate(:failed_modulus_check)
526
+ @errors[:branch_code] = Ibandit.translate(:branch_code_does_not_exist)
523
527
  false
524
528
  end
525
529
 
@@ -13,7 +13,7 @@ module Ibandit
13
13
  end
14
14
 
15
15
  def self.bank_info_table
16
- @swedish_bank_lookup ||=
16
+ @bank_info_table ||=
17
17
  begin
18
18
  relative_path = "../../../../data/raw/swedish_bank_lookup.yml"
19
19
  raw_info = YAML.load_file(File.expand_path(relative_path, __FILE__))
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ibandit
4
- VERSION = "1.20.0"
4
+ VERSION = "1.22.0"
5
5
  end
data/lib/ibandit.rb CHANGED
@@ -30,10 +30,8 @@ module Ibandit
30
30
  end
31
31
 
32
32
  def structures
33
- @structures ||= YAML.safe_load(
34
- File.read(File.expand_path("../data/structures.yml", __dir__)),
35
- permitted_classes: [Range, Symbol],
36
- )
33
+ @structures ||= YAML.safe_load_file(File.expand_path("../data/structures.yml", __dir__),
34
+ permitted_classes: [Range, Symbol])
37
35
  end
38
36
 
39
37
  def translate(key, options = {})
@@ -293,11 +293,11 @@ describe Ibandit::IBANAssembler do
293
293
  it_behaves_like "allows round trips", "ES80 2310 0001 1800 0001 2345"
294
294
 
295
295
  context "without a bank_code or branch code" do
296
- before { args.delete(:bank_code) }
297
-
298
- before { args.delete(:branch_code) }
299
-
300
- before { args[:account_number] = "23100001180000012345" }
296
+ before do
297
+ args.delete(:bank_code)
298
+ args.delete(:branch_code)
299
+ args[:account_number] = "23100001180000012345"
300
+ end
301
301
 
302
302
  it { is_expected.to be_nil }
303
303
  end
@@ -487,27 +487,29 @@ describe Ibandit::IBANAssembler do
487
487
  it_behaves_like "allows round trips", "HU42 1177 3016 1111 1018 0000 0000"
488
488
 
489
489
  context "without a bank_code or branch_code" do
490
- before { args.delete(:bank_code) }
491
-
492
- before { args.delete(:branch_code) }
493
-
494
- before { args[:account_number] = "11773016-11111018-00000000" }
490
+ before do
491
+ args.delete(:bank_code)
492
+ args.delete(:branch_code)
493
+ args[:account_number] = "11773016-11111018-00000000"
494
+ end
495
495
 
496
496
  it { is_expected.to be_nil }
497
497
  end
498
498
 
499
499
  context "without a bank_code" do
500
- before { args.delete(:bank_code) }
501
-
502
- before { args[:account_number] = "11773016-11111018-00000000" }
500
+ before do
501
+ args.delete(:bank_code)
502
+ args[:account_number] = "11773016-11111018-00000000"
503
+ end
503
504
 
504
505
  it { is_expected.to be_nil }
505
506
  end
506
507
 
507
508
  context "without a branch_code" do
508
- before { args.delete(:branch_code) }
509
-
510
- before { args[:account_number] = "11773016-11111018-00000000" }
509
+ before do
510
+ args.delete(:branch_code)
511
+ args[:account_number] = "11773016-11111018-00000000"
512
+ end
511
513
 
512
514
  it { is_expected.to be_nil }
513
515
  end
@@ -826,9 +828,10 @@ describe Ibandit::IBANAssembler do
826
828
  it_behaves_like "allows round trips", "NO93 8601 1117 947"
827
829
 
828
830
  context "without a bank_code" do
829
- before { args.delete(:bank_code) }
830
-
831
- before { args[:account_number] = "86011117947" }
831
+ before do
832
+ args.delete(:bank_code)
833
+ args[:account_number] = "86011117947"
834
+ end
832
835
 
833
836
  it { is_expected.to be_nil }
834
837
  end
@@ -854,9 +857,10 @@ describe Ibandit::IBANAssembler do
854
857
  it_behaves_like "allows round trips", "PL60 1020 1026 0000 0422 7020 1111"
855
858
 
856
859
  context "without a bank_code" do
857
- before { args.delete(:bank_code) }
858
-
859
- before { args[:account_number] = "60102010260000042270201111" }
860
+ before do
861
+ args.delete(:bank_code)
862
+ args[:account_number] = "60102010260000042270201111"
863
+ end
860
864
 
861
865
  it { is_expected.to be_nil }
862
866
  end
@@ -11,9 +11,7 @@ describe Ibandit::IBAN do
11
11
  its(:iban) { is_expected.to eq(iban_code) }
12
12
 
13
13
  context "with locales" do
14
- all_keys = YAML.safe_load(
15
- File.read("config/locales/en.yml"),
16
- )["en"]["ibandit"].keys
14
+ all_keys = YAML.safe_load_file("config/locales/en.yml")["en"]["ibandit"].keys
17
15
 
18
16
  Ibandit::Constants::SUPPORTED_LOCALES.each do |locale|
19
17
  context "for #{locale}", locale: locale do
@@ -129,19 +127,19 @@ describe Ibandit::IBAN do
129
127
  end
130
128
 
131
129
  context "when the IBAN was created from a Belgian IBAN" do
132
- let(:iban_code) { "BE62510007547061" }
130
+ let(:iban_code) { "BE68539007547034" }
133
131
 
134
132
  its(:country_code) { is_expected.to eq("BE") }
135
- its(:bank_code) { is_expected.to eq("510") }
133
+ its(:bank_code) { is_expected.to eq("539") }
136
134
  its(:branch_code) { is_expected.to be_nil }
137
- its(:account_number) { is_expected.to eq("510007547061") }
135
+ its(:account_number) { is_expected.to eq("539007547034") }
138
136
  its(:account_number_suffix) { is_expected.to be_nil }
139
- its(:swift_bank_code) { is_expected.to eq("510") }
137
+ its(:swift_bank_code) { is_expected.to eq("539") }
140
138
  its(:swift_branch_code) { is_expected.to be_nil }
141
- its(:swift_account_number) { is_expected.to eq("510007547061") }
142
- its(:swift_national_id) { is_expected.to eq("510") }
143
- its(:local_check_digits) { is_expected.to eq("61") }
144
- its(:bban) { is_expected.to eq("510007547061") }
139
+ its(:swift_account_number) { is_expected.to eq("539007547034") }
140
+ its(:swift_national_id) { is_expected.to eq("539") }
141
+ its(:local_check_digits) { is_expected.to eq("34") }
142
+ its(:bban) { is_expected.to eq("539007547034") }
145
143
  end
146
144
 
147
145
  context "when the IBAN was created with local details" do
@@ -869,6 +867,23 @@ describe Ibandit::IBAN do
869
867
  expect(subject.errors).to eq(account_number: "format is invalid")
870
868
  end
871
869
  end
870
+
871
+ # Spanish IBANs have recently switched to 8 character national IDs
872
+ context "with a Spanish IBAN" do
873
+ let(:iban_code) { "ES9121000418450200051332" }
874
+
875
+ its(:country_code) { is_expected.to eq("ES") }
876
+ its(:bank_code) { is_expected.to eq("2100") }
877
+ its(:branch_code) { is_expected.to eq("0418") }
878
+ its(:account_number) { is_expected.to eq("450200051332") }
879
+ its(:account_number_suffix) { is_expected.to be_nil }
880
+ its(:swift_bank_code) { is_expected.to eq("2100") }
881
+ its(:swift_branch_code) { is_expected.to eq("0418") }
882
+ its(:swift_account_number) { is_expected.to eq("450200051332") }
883
+ its(:swift_national_id) { is_expected.to eq("21000418") }
884
+ its(:local_check_digits) { is_expected.to eq("45") }
885
+ its(:bban) { is_expected.to eq("21000418450200051332") }
886
+ end
872
887
  end
873
888
 
874
889
  describe "#to_s" do
@@ -1318,12 +1333,11 @@ describe Ibandit::IBAN do
1318
1333
  valid_branch_code?: valid_branch_code,
1319
1334
  valid_account_number?: valid_account_number,
1320
1335
  )
1336
+ iban.valid_local_modulus_check?
1321
1337
  end
1322
1338
 
1323
1339
  after { Ibandit.modulus_checker = nil }
1324
1340
 
1325
- before { iban.valid_local_modulus_check? }
1326
-
1327
1341
  context "with an invalid bank code" do
1328
1342
  let(:iban_code) { "AT611904300234573201" }
1329
1343
  let(:valid_bank_code) { false }
@@ -1341,7 +1355,7 @@ describe Ibandit::IBAN do
1341
1355
  it { is_expected.to be(false) }
1342
1356
 
1343
1357
  it "sets the errors on the IBAN" do
1344
- expect(iban.errors).to include(bank_code: "did not pass modulus check")
1358
+ expect(iban.errors).to include(bank_code: "bank code does not exist")
1345
1359
  end
1346
1360
  end
1347
1361
 
@@ -1351,12 +1365,13 @@ describe Ibandit::IBAN do
1351
1365
  let(:valid_branch_code) { false }
1352
1366
  let(:valid_account_number) { true }
1353
1367
 
1354
- before { Ibandit.bic_finder = double(call: "BARCGB22XXX") }
1368
+ before do
1369
+ Ibandit.bic_finder = double(call: "BARCGB22XXX")
1370
+ iban.valid_local_modulus_check?
1371
+ end
1355
1372
 
1356
1373
  after { Ibandit.bic_finder = nil }
1357
1374
 
1358
- before { iban.valid_local_modulus_check? }
1359
-
1360
1375
  it "calls valid_branch_code? with an IBAN object" do
1361
1376
  expect(Ibandit.modulus_checker).
1362
1377
  to receive(:valid_branch_code?).
@@ -1368,7 +1383,7 @@ describe Ibandit::IBAN do
1368
1383
  it { is_expected.to be(false) }
1369
1384
 
1370
1385
  it "sets the errors on the IBAN" do
1371
- expect(iban.errors).to include(branch_code: "did not pass modulus check")
1386
+ expect(iban.errors).to include(branch_code: "branch code does not exist")
1372
1387
  end
1373
1388
  end
1374
1389
 
@@ -1581,7 +1596,7 @@ describe Ibandit::IBAN do
1581
1596
  it { is_expected.to be(false) }
1582
1597
 
1583
1598
  it "sets the errors on the IBAN" do
1584
- expect(iban.errors).to include(branch_code: "did not pass modulus check")
1599
+ expect(iban.errors).to include(branch_code: "branch code does not exist")
1585
1600
  end
1586
1601
  end
1587
1602
  end
@@ -1646,7 +1661,7 @@ describe Ibandit::IBAN do
1646
1661
  it { is_expected.to be(false) }
1647
1662
 
1648
1663
  it "sets the errors on the IBAN" do
1649
- expect(iban.errors).to include(branch_code: "did not pass modulus check")
1664
+ expect(iban.errors).to include(branch_code: "branch code does not exist")
1650
1665
  end
1651
1666
  end
1652
1667
  end
@@ -1711,7 +1726,7 @@ describe Ibandit::IBAN do
1711
1726
  it { is_expected.to be(false) }
1712
1727
 
1713
1728
  it "sets the errors on the IBAN" do
1714
- expect(iban.errors).to include(branch_code: "did not pass modulus check")
1729
+ expect(iban.errors).to include(branch_code: "branch code does not exist")
1715
1730
  end
1716
1731
  end
1717
1732
  end
@@ -2235,6 +2250,31 @@ describe Ibandit::IBAN do
2235
2250
  let(:valid_iban) { "RU0204452560040702810412345678901" }
2236
2251
  let(:invalid_iban) { "RUXX0204452560040702810412345678901" }
2237
2252
  end
2253
+
2254
+ it_behaves_like "a country's IBAN", "SO" do
2255
+ let(:valid_iban) { "SO211000001001000100141" }
2256
+ let(:invalid_iban) { "SO411000001001000100141" }
2257
+ end
2258
+
2259
+ it_behaves_like "a country's IBAN", "NI" do
2260
+ let(:valid_iban) { "NI45BAPR00000013000003558124" }
2261
+ let(:invalid_iban) { "NI55BAPR00000013000003558124" }
2262
+ end
2263
+
2264
+ it_behaves_like "a country's IBAN", "FK" do
2265
+ let(:valid_iban) { "FK88SC123456789012" }
2266
+ let(:invalid_iban) { "FK8SC123456789012" }
2267
+ end
2268
+
2269
+ it_behaves_like "a country's IBAN", "OM" do
2270
+ let(:valid_iban) { "OM810180000001299123456" }
2271
+ let(:invalid_iban) { "OM10180000001299123456" }
2272
+ end
2273
+
2274
+ it_behaves_like "a country's IBAN", "YE" do
2275
+ let(:valid_iban) { "YE15CBYE0001018861234567891234" }
2276
+ let(:invalid_iban) { "YE1CBYE0001018861234567891234" }
2277
+ end
2238
2278
  end
2239
2279
 
2240
2280
  describe "#local_check_digits" do