ibandit 1.14.0 → 1.15.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,6 +10,22 @@ describe Ibandit::IBAN do
10
10
 
11
11
  its(:iban) { is_expected.to eq(iban_code) }
12
12
 
13
+ context "with locales" do
14
+ all_keys = YAML.safe_load(
15
+ File.read("config/locales/en.yml"),
16
+ )["en"]["ibandit"].keys
17
+
18
+ Ibandit::Constants::SUPPORTED_LOCALES.each do |locale|
19
+ context "for #{locale}", locale: locale do
20
+ all_keys.each do |error_key|
21
+ it "has a translation for #{error_key}" do
22
+ expect { Ibandit.translate(error_key) }.to_not raise_error
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+
13
29
  context "with a poorly formatted IBAN" do
14
30
  let(:iban_code) { " gb82 WeSt 1234 5698 7654 32\n" }
15
31
 
@@ -396,8 +412,8 @@ describe Ibandit::IBAN do
396
412
 
397
413
  it "is invalid and has the correct errors" do
398
414
  expect(subject.valid?).to eq(false)
399
- expect(subject.errors).to eq(account_number: "is invalid",
400
- branch_code: "is invalid")
415
+ expect(subject.errors).to eq(account_number: "format is invalid",
416
+ branch_code: "format is invalid")
401
417
  end
402
418
  end
403
419
 
@@ -699,7 +715,7 @@ describe Ibandit::IBAN do
699
715
 
700
716
  it "returns an error on bank_code attribute" do
701
717
  expect(subject.valid?).to eq(false)
702
- expect(subject.errors).to eq(bank_code: "is invalid")
718
+ expect(subject.errors).to eq(bank_code: "did not pass checksum test")
703
719
  end
704
720
  end
705
721
 
@@ -794,7 +810,7 @@ describe Ibandit::IBAN do
794
810
 
795
811
  it "is invalid and has an error populated" do
796
812
  expect(subject.valid?).to eq(false)
797
- expect(subject.errors).to eq(account_number: "is invalid")
813
+ expect(subject.errors).to eq(account_number: "format is invalid")
798
814
  end
799
815
  end
800
816
  end
@@ -853,41 +869,11 @@ describe Ibandit::IBAN do
853
869
 
854
870
  it { is_expected.to eq(false) }
855
871
 
856
- context "locale en", locale: :en do
857
- it "sets errors on the IBAN" do
858
- iban.valid_country_code?
859
- expect(iban.errors).
860
- to include(country_code: "'AA' is not a valid ISO 3166-1 IBAN " \
861
- "country code")
862
- end
863
- end
864
-
865
- context "locale de", locale: :de do
866
- it "sets errors on the IBAN" do
867
- iban.valid_country_code?
868
- expect(iban.errors).
869
- to include(country_code: "'AA' ist kein gültiges " \
870
- "IBAN-Länderkennzeichen gemäß ISO 3166-1")
871
- end
872
- end
873
-
874
- context "locale pt", locale: :pt do
875
- it "sets errors on the IBAN" do
876
- iban.valid_country_code?
877
- expect(iban.errors).
878
- to include(country_code: "'AA' não corresponde a um código de " \
879
- "país do IBAN válido segundo a norma " \
880
- "ISO 3166-1")
881
- end
882
- end
883
-
884
- context "locale nl", locale: :nl do
885
- it "sets errors on the IBAN" do
886
- iban.valid_country_code?
887
- expect(iban.errors).
888
- to include(country_code: "'AA' is geen geldig ISO 3166-1 IBAN " \
889
- "landcode")
890
- end
872
+ it "sets errors on the IBAN" do
873
+ iban.valid_country_code?
874
+ expect(iban.errors).to include(
875
+ country_code: "'AA' is not a valid ISO 3166-1 IBAN country code",
876
+ )
891
877
  end
892
878
  end
893
879
  end
@@ -912,112 +898,12 @@ describe Ibandit::IBAN do
912
898
 
913
899
  it { is_expected.to eq(false) }
914
900
 
915
- context "locale en", locale: :en do
916
- it "sets errors on the IBAN" do
917
- iban.valid_check_digits?
918
- expect(iban.errors).
919
- to include(check_digits: "Check digits failed modulus check. " \
920
- "Expected '82', received '12'.")
921
- end
922
- end
923
-
924
- context "locale fr", locale: :fr do
925
- it "sets errors on the IBAN" do
926
- iban.valid_check_digits?
927
- expect(iban.errors).
928
- to include(check_digits: "Les chiffres de contrôle n'ont pas " \
929
- "satisfait au contrôle de validité. " \
930
- "Attendus '82', reçus '12'.")
931
- end
932
- end
933
-
934
- context "locale de", locale: :de do
935
- it "sets errors on the IBAN" do
936
- iban.valid_check_digits?
937
- expect(iban.errors).
938
- to include(check_digits: "Prüfziffer hat Betragsprüfung nicht " \
939
- "bestanden. (82 Zeichen erwartet, 12 " \
940
- "angegeben).")
941
- end
942
- end
943
-
944
- context "locale pt", locale: :pt do
945
- it "sets errors on the IBAN" do
946
- iban.valid_check_digits?
947
- expect(iban.errors).
948
- to include(check_digits: "Verifique os dígitos. A verificação " \
949
- "do módulo falhou. '82' esperados, '12' " \
950
- "recebidos.")
951
- end
952
- end
953
-
954
- context "locale es", locale: :es do
955
- it "sets errors on the IBAN" do
956
- iban.valid_check_digits?
957
- expect(iban.errors).
958
- to include(check_digits: "Los dígitos de verificación han " \
959
- "generado un error en la comprobación " \
960
- "del módulo. Se esperaba \"82\", pero " \
961
- "se ha recibido \"12\".")
962
- end
963
- end
964
-
965
- context "locale it", locale: :it do
966
- it "sets errors on the IBAN" do
967
- iban.valid_check_digits?
968
- expect(iban.errors).
969
- to include(check_digits: "Controllo del modulo non riuscito per " \
970
- "i caratteri. 82 caratteri previsti, 12 " \
971
- "immessi.")
972
- end
973
- end
974
-
975
- context "locale nl", locale: :nl do
976
- it "sets errors on the IBAN" do
977
- iban.valid_check_digits?
978
- expect(iban.errors).
979
- to include(check_digits: "Controlegetal mislukte modulus check. " \
980
- "Verwachte '82', ontvangen '12'.")
981
- end
982
- end
983
-
984
- context "locale nb", locale: :nb do
985
- it "sets errors on the IBAN" do
986
- iban.valid_check_digits?
987
- expect(iban.errors).
988
- to include(check_digits: "Tallkontrollen mislyktes i " \
989
- "moduluskontrollen. Forventet '82'" \
990
- ", mottok '12'.")
991
- end
992
- end
993
-
994
- context "locale sl", locale: :sl do
995
- it "sets errors on the IBAN" do
996
- iban.valid_check_digits?
997
- expect(iban.errors).
998
- to include(check_digits: "Številke čeka niso uspešno prestale " \
999
- "preverjanja modula. Pričakovano '82', " \
1000
- "prejeto '12'.")
1001
- end
1002
- end
1003
-
1004
- context "locale da", locale: :da do
1005
- it "sets errors on the IBAN" do
1006
- iban.valid_check_digits?
1007
- expect(iban.errors).
1008
- to include(check_digits: "Kontrolcifre bestod ikke modulustjek. " \
1009
- "Forventede '82'; modtog '12'.")
1010
- end
1011
- end
1012
-
1013
- context "locale sv", locale: :sv do
1014
- it "sets errors on the IBAN" do
1015
- iban.valid_check_digits?
1016
- expect(iban.errors).
1017
- to include(check_digits: "Kontrollera felaktiga siffror med " \
1018
- "modulkontroll. Förväntade '82', " \
1019
- "mottagna '12'.")
1020
- end
901
+ it "sets errors on the IBAN" do
902
+ iban.valid_check_digits?
903
+ expect(iban.errors).to include(
904
+ check_digits: "Check digits failed modulus check. " \
905
+ "Expected '82', received '12'.",
906
+ )
1021
907
  end
1022
908
  end
1023
909
 
@@ -1056,111 +942,12 @@ describe Ibandit::IBAN do
1056
942
 
1057
943
  it { is_expected.to eq(false) }
1058
944
 
1059
- context "locale en", locale: :en do
1060
- it "sets errors on the IBAN" do
1061
- iban.valid_length?
1062
- expect(iban.errors).
1063
- to include(length: "Length doesn't match SWIFT specification " \
1064
- "(expected 22 characters, received 20)")
1065
- end
1066
- end
1067
-
1068
- context "locale fr", locale: :fr do
1069
- it "sets errors on the IBAN" do
1070
- iban.valid_length?
1071
- expect(iban.errors).
1072
- to include(length: "La longueur ne correspond pas à la " \
1073
- "spécification SWIFT (22 caractères attendus, " \
1074
- "20 reçus)")
1075
- end
1076
- end
1077
-
1078
- context "locale de", locale: :de do
1079
- it "sets errors on the IBAN" do
1080
- iban.valid_length?
1081
- expect(iban.errors).
1082
- to include(length: "Länge entspricht nicht der " \
1083
- "SWIFT-Spezifikation (22 Zeichen erwartet, " \
1084
- "20 angegeben)")
1085
- end
1086
- end
1087
-
1088
- context "locale pt", locale: :pt do
1089
- it "sets errors on the IBAN" do
1090
- iban.valid_length?
1091
- expect(iban.errors).
1092
- to include(length: "O comprimento não corresponde à especificação " \
1093
- "do código SWIFT (22 caracteres esperados, 20 " \
1094
- "recebidos)")
1095
- end
1096
- end
1097
-
1098
- context "locale es", locale: :es do
1099
- it "sets errors on the IBAN" do
1100
- iban.valid_length?
1101
- expect(iban.errors).
1102
- to include(length: "La longitud no coincide con la especificación " \
1103
- "SWIFT (se esperaban 22 caracteres, pero se " \
1104
- "han recibido 20)")
1105
- end
1106
- end
1107
-
1108
- context "locale it", locale: :it do
1109
- it "sets errors on the IBAN" do
1110
- iban.valid_length?
1111
- expect(iban.errors).
1112
- to include(length: "La lunghezza non corrisponde alla specifica " \
1113
- "SWIFT (22 caratteri previsti, 20 immessi)")
1114
- end
1115
- end
1116
-
1117
- context "locale nl", locale: :nl do
1118
- it "sets errors on the IBAN" do
1119
- iban.valid_length?
1120
- expect(iban.errors).
1121
- to include(length: "Lengte komt niet overeen met SWIFT-" \
1122
- "specificatie (verwachte 22 karakters, " \
1123
- "ontvangen 20)")
1124
- end
1125
- end
1126
-
1127
- context "locale nb", locale: :nb do
1128
- it "sets errors on the IBAN" do
1129
- iban.valid_length?
1130
- expect(iban.errors).
1131
- to include(length: "Lengden samsvarer ikke med " \
1132
- "SWIFT-spesifikasjonene (forventet 22 tegn, " \
1133
- "mottok 20)")
1134
- end
1135
- end
1136
-
1137
- context "locale sl", locale: :sl do
1138
- it "sets errors on the IBAN" do
1139
- iban.valid_length?
1140
- expect(iban.errors).
1141
- to include(length: "Dolžina se ne ujema z opredelitvijo za " \
1142
- "kodo SWIFT (pričakovani znaki: 22, " \
1143
- "prejeti znaki: 20)")
1144
- end
1145
- end
1146
-
1147
- context "locale da", locale: :da do
1148
- it "sets errors on the IBAN" do
1149
- iban.valid_length?
1150
- expect(iban.errors).
1151
- to include(length: "Længden modsvarer ikke SWIFT-specifikation " \
1152
- "(forventede 22 tegn, modtog 20)")
1153
- end
1154
- end
1155
-
1156
- context "locale sv", locale: :sv do
1157
- it "sets errors on the IBAN" do
1158
- iban.valid_length?
1159
- expect(iban.errors).
1160
- to include(length: "Längd matchar inte förväntad " \
1161
- "SWIFT-specifikation (förväntade 22 tecken, " \
1162
- "mottagna 20)")
1163
- end
945
+ it "sets errors on the IBAN" do
946
+ iban.valid_length?
947
+ expect(iban.errors).to include(
948
+ length: "Length doesn't match SWIFT specification " \
949
+ "(expected 22 characters, received 20)",
950
+ )
1164
951
  end
1165
952
  end
1166
953
 
@@ -1188,99 +975,11 @@ describe Ibandit::IBAN do
1188
975
 
1189
976
  it { is_expected.to eq(false) }
1190
977
 
1191
- context "locale en", locale: :en do
1192
- it "sets errors on the IBAN" do
1193
- iban.valid_bank_code_length?
1194
- expect(iban.errors).
1195
- to include(bank_code: "is the wrong length (should be 4 " \
1196
- "characters)")
1197
- end
1198
- end
1199
-
1200
- context "locale fr", locale: :fr do
1201
- it "sets errors on the IBAN" do
1202
- iban.valid_bank_code_length?
1203
- expect(iban.errors).
1204
- to include(bank_code: "est une longueur incorrecte (doit " \
1205
- "contenir 4 caractères)")
1206
- end
1207
- end
1208
-
1209
- context "locale de", locale: :de do
1210
- it "sets errors on the IBAN" do
1211
- iban.valid_bank_code_length?
1212
- expect(iban.errors).
1213
- to include(bank_code: "hat nicht die richtige Länge (sollte " \
1214
- "4 Zeichen haben)")
1215
- end
1216
- end
1217
-
1218
- context "locale pt", locale: :pt do
1219
- it "sets errors on the IBAN" do
1220
- iban.valid_bank_code_length?
1221
- expect(iban.errors).
1222
- to include(bank_code: "não tem o comprimento correto (deve " \
1223
- "ter 4 caracteres)")
1224
- end
1225
- end
1226
-
1227
- context "locale es", locale: :es do
1228
- it "sets errors on the IBAN" do
1229
- iban.valid_bank_code_length?
1230
- expect(iban.errors).
1231
- to include(bank_code: "no tiene la longitud correcta (debe " \
1232
- "tener 4 caracteres)")
1233
- end
1234
- end
1235
-
1236
- context "locale it", locale: :it do
1237
- it "sets errors on the IBAN" do
1238
- iban.valid_bank_code_length?
1239
- expect(iban.errors).
1240
- to include(bank_code: "non ha la lunghezza richiesta (deve " \
1241
- "essere di 4 caratteri)")
1242
- end
1243
- end
1244
-
1245
- context "locale nl", locale: :nl do
1246
- it "sets errors on the IBAN" do
1247
- iban.valid_bank_code_length?
1248
- expect(iban.errors).
1249
- to include(bank_code: "heeft onjuiste lengte (moet 4 tekens " \
1250
- "lang zijn)")
1251
- end
1252
- end
1253
-
1254
- context "locale nb", locale: :nb do
1255
- it "sets errors on the IBAN" do
1256
- iban.valid_bank_code_length?
1257
- expect(iban.errors).
1258
- to include(bank_code: "har feil lengde (skal være 4 tegn)")
1259
- end
1260
- end
1261
-
1262
- context "locale sl", locale: :sl do
1263
- it "sets errors on the IBAN" do
1264
- iban.valid_bank_code_length?
1265
- expect(iban.errors).
1266
- to include(bank_code: "je napačne dolžine (biti mora 4 znakov)")
1267
- end
1268
- end
1269
-
1270
- context "locale da", locale: :da do
1271
- it "sets errors on the IBAN" do
1272
- iban.valid_bank_code_length?
1273
- expect(iban.errors).
1274
- to include(bank_code: "har forkert længde (skulle være 4 tegn)")
1275
- end
1276
- end
1277
-
1278
- context "locale sv", locale: :sv do
1279
- it "sets errors on the IBAN" do
1280
- iban.valid_bank_code_length?
1281
- expect(iban.errors).
1282
- to include(bank_code: "har fel längd (bör vara 4 tecken)")
1283
- end
978
+ it "sets errors on the IBAN" do
979
+ iban.valid_bank_code_length?
980
+ expect(iban.errors).to include(
981
+ bank_code: "is the wrong length (should be 4 characters)",
982
+ )
1284
983
  end
1285
984
  end
1286
985
 
@@ -1308,99 +1007,11 @@ describe Ibandit::IBAN do
1308
1007
 
1309
1008
  it { is_expected.to eq(false) }
1310
1009
 
1311
- context "locale en", locale: :en do
1312
- it "sets errors on the IBAN" do
1313
- iban.valid_branch_code_length?
1314
- expect(iban.errors).
1315
- to include(branch_code: "is the wrong length (should be 6 " \
1316
- "characters)")
1317
- end
1318
- end
1319
-
1320
- context "locale fr", locale: :fr do
1321
- it "sets errors on the IBAN" do
1322
- iban.valid_branch_code_length?
1323
- expect(iban.errors).
1324
- to include(branch_code: "est une longueur incorrecte (doit " \
1325
- "contenir 6 caractères)")
1326
- end
1327
- end
1328
-
1329
- context "locale de", locale: :de do
1330
- it "sets errors on the IBAN" do
1331
- iban.valid_branch_code_length?
1332
- expect(iban.errors).
1333
- to include(branch_code: "hat nicht die richtige Länge (sollte " \
1334
- "6 Zeichen haben)")
1335
- end
1336
- end
1337
-
1338
- context "locale pt", locale: :pt do
1339
- it "sets errors on the IBAN" do
1340
- iban.valid_branch_code_length?
1341
- expect(iban.errors).
1342
- to include(branch_code: "não tem o comprimento correto (deve " \
1343
- "ter 6 caracteres)")
1344
- end
1345
- end
1346
-
1347
- context "locale es", locale: :es do
1348
- it "sets errors on the IBAN" do
1349
- iban.valid_branch_code_length?
1350
- expect(iban.errors).
1351
- to include(branch_code: "no tiene la longitud correcta (debe " \
1352
- "tener 6 caracteres)")
1353
- end
1354
- end
1355
-
1356
- context "locale it", locale: :it do
1357
- it "sets errors on the IBAN" do
1358
- iban.valid_branch_code_length?
1359
- expect(iban.errors).
1360
- to include(branch_code: "non ha la lunghezza richiesta (deve " \
1361
- "essere di 6 caratteri)")
1362
- end
1363
- end
1364
-
1365
- context "locale nl", locale: :nl do
1366
- it "sets errors on the IBAN" do
1367
- iban.valid_branch_code_length?
1368
- expect(iban.errors).
1369
- to include(branch_code: "heeft onjuiste lengte (moet 6 tekens " \
1370
- "lang zijn)")
1371
- end
1372
- end
1373
-
1374
- context "locale nb", locale: :nb do
1375
- it "sets errors on the IBAN" do
1376
- iban.valid_branch_code_length?
1377
- expect(iban.errors).
1378
- to include(branch_code: "har feil lengde (skal være 6 tegn)")
1379
- end
1380
- end
1381
-
1382
- context "locale sl", locale: :sl do
1383
- it "sets errors on the IBAN" do
1384
- iban.valid_branch_code_length?
1385
- expect(iban.errors).
1386
- to include(branch_code: "je napačne dolžine (biti mora 6 znakov)")
1387
- end
1388
- end
1389
-
1390
- context "locale da", locale: :da do
1391
- it "sets errors on the IBAN" do
1392
- iban.valid_branch_code_length?
1393
- expect(iban.errors).
1394
- to include(branch_code: "har forkert længde (skulle være 6 tegn)")
1395
- end
1396
- end
1397
-
1398
- context "locale sv", locale: :sv do
1399
- it "sets errors on the IBAN" do
1400
- iban.valid_branch_code_length?
1401
- expect(iban.errors).
1402
- to include(branch_code: "har fel längd (bör vara 6 tecken)")
1403
- end
1010
+ it "sets errors on the IBAN" do
1011
+ iban.valid_branch_code_length?
1012
+ expect(iban.errors).to include(
1013
+ branch_code: "is the wrong length (should be 6 characters)",
1014
+ )
1404
1015
  end
1405
1016
  end
1406
1017
 
@@ -1409,81 +1020,9 @@ describe Ibandit::IBAN do
1409
1020
 
1410
1021
  it { is_expected.to eq(false) }
1411
1022
 
1412
- context "locale en", locale: :en do
1413
- it "sets errors on the IBAN" do
1414
- iban.valid_branch_code_length?
1415
- expect(iban.errors).to include(branch_code: "is required")
1416
- end
1417
- end
1418
-
1419
- context "locale fr", locale: :fr do
1420
- it "sets errors on the IBAN" do
1421
- iban.valid_branch_code_length?
1422
- expect(iban.errors).to include(branch_code: "est obligatoire")
1423
- end
1424
- end
1425
-
1426
- context "locale de", locale: :de do
1427
- it "sets errors on the IBAN" do
1428
- iban.valid_branch_code_length?
1429
- expect(iban.errors).to include(branch_code: "ist erforderlich")
1430
- end
1431
- end
1432
-
1433
- context "locale pt", locale: :pt do
1434
- it "sets errors on the IBAN" do
1435
- iban.valid_branch_code_length?
1436
- expect(iban.errors).to include(branch_code: "é obrigatório")
1437
- end
1438
- end
1439
-
1440
- context "locale es", locale: :es do
1441
- it "sets errors on the IBAN" do
1442
- iban.valid_branch_code_length?
1443
- expect(iban.errors).to include(branch_code: "es obligatorio")
1444
- end
1445
- end
1446
-
1447
- context "locale it", locale: :it do
1448
- it "sets errors on the IBAN" do
1449
- iban.valid_branch_code_length?
1450
- expect(iban.errors).to include(branch_code: "è obbligatorio")
1451
- end
1452
- end
1453
-
1454
- context "locale nl", locale: :nl do
1455
- it "sets errors on the IBAN" do
1456
- iban.valid_branch_code_length?
1457
- expect(iban.errors).to include(branch_code: "moet opgegeven zijn")
1458
- end
1459
- end
1460
-
1461
- context "locale nb", locale: :nb do
1462
- it "sets errors on the IBAN" do
1463
- iban.valid_branch_code_length?
1464
- expect(iban.errors).to include(branch_code: "er påkrevd")
1465
- end
1466
- end
1467
-
1468
- context "locale sl", locale: :sl do
1469
- it "sets errors on the IBAN" do
1470
- iban.valid_branch_code_length?
1471
- expect(iban.errors).to include(branch_code: "je obvezno")
1472
- end
1473
- end
1474
-
1475
- context "locale da", locale: :da do
1476
- it "sets errors on the IBAN" do
1477
- iban.valid_branch_code_length?
1478
- expect(iban.errors).to include(branch_code: "er påkrævet")
1479
- end
1480
- end
1481
-
1482
- context "locale sv", locale: :sv do
1483
- it "sets errors on the IBAN" do
1484
- iban.valid_branch_code_length?
1485
- expect(iban.errors).to include(branch_code: "krävs")
1486
- end
1023
+ it "sets errors on the IBAN" do
1024
+ iban.valid_branch_code_length?
1025
+ expect(iban.errors).to include(branch_code: "is required")
1487
1026
  end
1488
1027
  end
1489
1028
 
@@ -1513,118 +1052,28 @@ describe Ibandit::IBAN do
1513
1052
 
1514
1053
  it { is_expected.to eq(false) }
1515
1054
 
1516
- context "locale en", locale: :en do
1517
- it "sets errors on the IBAN" do
1518
- iban.valid_account_number_length?
1519
- expect(iban.errors).
1520
- to include(account_number: "is the wrong length (should be 8 " \
1521
- "characters)")
1522
- end
1055
+ it "sets errors on the IBAN" do
1056
+ iban.valid_account_number_length?
1057
+ expect(iban.errors).to include(
1058
+ account_number: "is the wrong length (should be 8 characters)",
1059
+ )
1523
1060
  end
1061
+ end
1524
1062
 
1525
- context "locale fr", locale: :fr do
1526
- it "sets errors on the IBAN" do
1527
- iban.valid_account_number_length?
1528
- expect(iban.errors).
1529
- to include(account_number: "est une longueur incorrecte (doit " \
1530
- "contenir 8 caractères)")
1531
- end
1532
- end
1063
+ context "with an invalid country_code" do
1064
+ before { allow(iban).to receive(:country_code).and_return("AA") }
1533
1065
 
1534
- context "locale de", locale: :de do
1535
- it "sets errors on the IBAN" do
1536
- iban.valid_account_number_length?
1537
- expect(iban.errors).
1538
- to include(account_number: "hat nicht die richtige Länge (sollte " \
1539
- "8 Zeichen haben)")
1540
- end
1541
- end
1066
+ it { is_expected.to be_nil }
1542
1067
 
1543
- context "locale pt", locale: :pt do
1544
- it "sets errors on the IBAN" do
1545
- iban.valid_account_number_length?
1546
- expect(iban.errors).
1547
- to include(account_number: "não tem o comprimento correto (deve " \
1548
- "ter 8 caracteres)")
1549
- end
1068
+ it "does not set errors on the IBAN" do
1069
+ iban.valid_account_number_length?
1070
+ expect(iban.errors).to_not include(:account_number)
1550
1071
  end
1072
+ end
1073
+ end
1551
1074
 
1552
- context "locale es", locale: :es do
1553
- it "sets errors on the IBAN" do
1554
- iban.valid_account_number_length?
1555
- expect(iban.errors).
1556
- to include(account_number: "no tiene la longitud correcta (debe " \
1557
- "tener 8 caracteres)")
1558
- end
1559
- end
1560
-
1561
- context "locale it", locale: :it do
1562
- it "sets errors on the IBAN" do
1563
- iban.valid_account_number_length?
1564
- expect(iban.errors).
1565
- to include(account_number: "non ha la lunghezza richiesta (deve " \
1566
- "essere di 8 caratteri)")
1567
- end
1568
- end
1569
-
1570
- context "locale nl", locale: :nl do
1571
- it "sets errors on the IBAN" do
1572
- iban.valid_account_number_length?
1573
- expect(iban.errors).
1574
- to include(account_number: "heeft onjuiste lengte (moet 8 " \
1575
- "tekens lang zijn)")
1576
- end
1577
- end
1578
-
1579
- context "locale nb", locale: :nb do
1580
- it "sets errors on the IBAN" do
1581
- iban.valid_account_number_length?
1582
- expect(iban.errors).
1583
- to include(account_number: "har feil lengde (skal være 8 tegn)")
1584
- end
1585
- end
1586
-
1587
- context "locale sl", locale: :sl do
1588
- it "sets errors on the IBAN" do
1589
- iban.valid_account_number_length?
1590
- expect(iban.errors).
1591
- to include(account_number: "je napačne dolžine (biti mora 8 " \
1592
- "znakov)")
1593
- end
1594
- end
1595
-
1596
- context "locale da", locale: :da do
1597
- it "sets errors on the IBAN" do
1598
- iban.valid_account_number_length?
1599
- expect(iban.errors).
1600
- to include(account_number: "har forkert længde (skulle være 8 " \
1601
- "tegn)")
1602
- end
1603
- end
1604
-
1605
- context "locale sv", locale: :sv do
1606
- it "sets errors on the IBAN" do
1607
- iban.valid_account_number_length?
1608
- expect(iban.errors).
1609
- to include(account_number: "har fel längd (bör vara 8 tecken)")
1610
- end
1611
- end
1612
- end
1613
-
1614
- context "with an invalid country_code" do
1615
- before { allow(iban).to receive(:country_code).and_return("AA") }
1616
-
1617
- it { is_expected.to be_nil }
1618
-
1619
- it "does not set errors on the IBAN" do
1620
- iban.valid_account_number_length?
1621
- expect(iban.errors).to_not include(:account_number)
1622
- end
1623
- end
1624
- end
1625
-
1626
- describe "#valid_characters?" do
1627
- subject { iban.valid_characters? }
1075
+ describe "#valid_characters?" do
1076
+ subject { iban.valid_characters? }
1628
1077
 
1629
1078
  context "with valid details" do
1630
1079
  let(:iban_code) { "GB82WEST12345698765432" }
@@ -1637,94 +1086,11 @@ describe Ibandit::IBAN do
1637
1086
 
1638
1087
  it { is_expected.to eq(false) }
1639
1088
 
1640
- context "locale en", locale: :en do
1641
- it "sets errors on the IBAN" do
1642
- iban.valid_characters?
1643
- expect(iban.errors).
1644
- to include(characters: "Non-alphanumeric characters found: -")
1645
- end
1646
- end
1647
-
1648
- context "locale fr", locale: :fr do
1649
- it "sets errors on the IBAN" do
1650
- iban.valid_characters?
1651
- expect(iban.errors).
1652
- to include(characters: "Caractères non alphanumériques trouvés : -")
1653
- end
1654
- end
1655
-
1656
- context "locale de", locale: :de do
1657
- it "sets errors on the IBAN" do
1658
- iban.valid_characters?
1659
- expect(iban.errors).
1660
- to include(characters: "Nicht-alphanumerischen Zeichen gefunden: -")
1661
- end
1662
- end
1663
-
1664
- context "locale pt", locale: :pt do
1665
- it "sets errors on the IBAN" do
1666
- iban.valid_characters?
1667
- expect(iban.errors).
1668
- to include(characters: "Caracteres não alfanuméricos " \
1669
- "encontrados: -")
1670
- end
1671
- end
1672
-
1673
- context "locale es", locale: :es do
1674
- it "sets errors on the IBAN" do
1675
- iban.valid_characters?
1676
- expect(iban.errors).
1677
- to include(characters: "Se han encontrado caracteres no " \
1678
- "alfanuméricos: -")
1679
- end
1680
- end
1681
-
1682
- context "locale it", locale: :it do
1683
- it "sets errors on the IBAN" do
1684
- iban.valid_characters?
1685
- expect(iban.errors).
1686
- to include(characters: "Caratteri non alfanumerici trovati: -")
1687
- end
1688
- end
1689
-
1690
- context "locale nl", locale: :nl do
1691
- it "sets errors on the IBAN" do
1692
- iban.valid_characters?
1693
- expect(iban.errors).
1694
- to include(characters: "Niet-alfanumerieke tekens gevonden: -")
1695
- end
1696
- end
1697
-
1698
- context "locale nb", locale: :nb do
1699
- it "sets errors on the IBAN" do
1700
- iban.valid_characters?
1701
- expect(iban.errors).
1702
- to include(characters: "Ikke-alfanumeriske tegn funnet: -")
1703
- end
1704
- end
1705
-
1706
- context "locale sl", locale: :sl do
1707
- it "sets errors on the IBAN" do
1708
- iban.valid_characters?
1709
- expect(iban.errors).
1710
- to include(characters: "Najdeni ne-alfanumerični znaki: -")
1711
- end
1712
- end
1713
-
1714
- context "locale da", locale: :da do
1715
- it "sets errors on the IBAN" do
1716
- iban.valid_characters?
1717
- expect(iban.errors).
1718
- to include(characters: "Ikke-alfanumeriske tegn registreret: -")
1719
- end
1720
- end
1721
-
1722
- context "locale sv", locale: :sv do
1723
- it "sets errors on the IBAN" do
1724
- iban.valid_characters?
1725
- expect(iban.errors).
1726
- to include(characters: "Icke alfanumeriska tecken hittades: -")
1727
- end
1089
+ it "sets errors on the IBAN" do
1090
+ iban.valid_characters?
1091
+ expect(iban.errors).to include(
1092
+ characters: "Non-alphanumeric characters found: -",
1093
+ )
1728
1094
  end
1729
1095
  end
1730
1096
  end
@@ -1743,92 +1109,9 @@ describe Ibandit::IBAN do
1743
1109
 
1744
1110
  it { is_expected.to eq(false) }
1745
1111
 
1746
- context "locale en", locale: :en do
1747
- it "sets errors on the IBAN" do
1748
- iban.valid_format?
1749
- expect(iban.errors).
1750
- to include(format: "Unexpected format for a GB IBAN.")
1751
- end
1752
- end
1753
-
1754
- context "locale fr", locale: :fr do
1755
- it "sets errors on the IBAN" do
1756
- iban.valid_format?
1757
- expect(iban.errors).
1758
- to include(format: "Format non attendu pour un IBAN GB.")
1759
- end
1760
- end
1761
-
1762
- context "locale de", locale: :de do
1763
- it "sets errors on the IBAN" do
1764
- iban.valid_format?
1765
- expect(iban.errors).
1766
- to include(format: "Unerwartetes Format für eine GB-IBAN.")
1767
- end
1768
- end
1769
-
1770
- context "locale pt", locale: :pt do
1771
- it "sets errors on the IBAN" do
1772
- iban.valid_format?
1773
- expect(iban.errors).
1774
- to include(format: "Formato inesperado para um IBAN GB.")
1775
- end
1776
- end
1777
-
1778
- context "locale es", locale: :es do
1779
- it "sets errors on the IBAN" do
1780
- iban.valid_format?
1781
- expect(iban.errors).
1782
- to include(format: "Formato inesperado para un IBAN de GB.")
1783
- end
1784
- end
1785
-
1786
- context "locale it", locale: :it do
1787
- it "sets errors on the IBAN" do
1788
- iban.valid_format?
1789
- expect(iban.errors).
1790
- to include(format: "Formato imprevisto per un IBAN GB.")
1791
- end
1792
- end
1793
-
1794
- context "locale nl", locale: :nl do
1795
- it "sets errors on the IBAN" do
1796
- iban.valid_format?
1797
- expect(iban.errors).
1798
- to include(format: "Onverwachte formaat voor een GB IBAN.")
1799
- end
1800
- end
1801
-
1802
- context "locale nb", locale: :nb do
1803
- it "sets errors on the IBAN" do
1804
- iban.valid_format?
1805
- expect(iban.errors).
1806
- to include(format: "Uventet format for IBAN for GB.")
1807
- end
1808
- end
1809
-
1810
- context "locale sl", locale: :sl do
1811
- it "sets errors on the IBAN" do
1812
- iban.valid_format?
1813
- expect(iban.errors).
1814
- to include(format: "Nepričakovana oblika zapisa GB v IBAN.")
1815
- end
1816
- end
1817
-
1818
- context "locale da", locale: :da do
1819
- it "sets errors on the IBAN" do
1820
- iban.valid_format?
1821
- expect(iban.errors).
1822
- to include(format: "Uventet format for en IBAN fra GB.")
1823
- end
1824
- end
1825
-
1826
- context "locale sv", locale: :sv do
1827
- it "sets errors on the IBAN" do
1828
- iban.valid_format?
1829
- expect(iban.errors).
1830
- to include(format: "Oväntat format för GB IBAN.")
1831
- end
1112
+ it "sets errors on the IBAN" do
1113
+ iban.valid_format?
1114
+ expect(iban.errors).to include(format: "Unexpected format for a GB IBAN.")
1832
1115
  end
1833
1116
  end
1834
1117
 
@@ -1859,81 +1142,9 @@ describe Ibandit::IBAN do
1859
1142
 
1860
1143
  it { is_expected.to eq(false) }
1861
1144
 
1862
- context "locale en", locale: :en do
1863
- it "sets errors on the IBAN" do
1864
- iban.valid_bank_code_format?
1865
- expect(iban.errors).to include(bank_code: "is invalid")
1866
- end
1867
- end
1868
-
1869
- context "locale fr", locale: :fr do
1870
- it "sets errors on the IBAN" do
1871
- iban.valid_bank_code_format?
1872
- expect(iban.errors).to include(bank_code: "n'est pas valide")
1873
- end
1874
- end
1875
-
1876
- context "locale de", locale: :de do
1877
- it "sets errors on the IBAN" do
1878
- iban.valid_bank_code_format?
1879
- expect(iban.errors).to include(bank_code: "ist ungültig")
1880
- end
1881
- end
1882
-
1883
- context "locale pt", locale: :pt do
1884
- it "sets errors on the IBAN" do
1885
- iban.valid_bank_code_format?
1886
- expect(iban.errors).to include(bank_code: "é inválido")
1887
- end
1888
- end
1889
-
1890
- context "locale es", locale: :es do
1891
- it "sets errors on the IBAN" do
1892
- iban.valid_bank_code_format?
1893
- expect(iban.errors).to include(bank_code: "no es válido")
1894
- end
1895
- end
1896
-
1897
- context "locale it", locale: :it do
1898
- it "sets errors on the IBAN" do
1899
- iban.valid_bank_code_format?
1900
- expect(iban.errors).to include(bank_code: "non è valido")
1901
- end
1902
- end
1903
-
1904
- context "locale nl", locale: :nl do
1905
- it "sets errors on the IBAN" do
1906
- iban.valid_bank_code_format?
1907
- expect(iban.errors).to include(bank_code: "is ongeldig")
1908
- end
1909
- end
1910
-
1911
- context "locale nb", locale: :nb do
1912
- it "sets errors on the IBAN" do
1913
- iban.valid_bank_code_format?
1914
- expect(iban.errors).to include(bank_code: "er ikke gyldig")
1915
- end
1916
- end
1917
-
1918
- context "locale sl", locale: :sl do
1919
- it "sets errors on the IBAN" do
1920
- iban.valid_bank_code_format?
1921
- expect(iban.errors).to include(bank_code: "ni veljavno")
1922
- end
1923
- end
1924
-
1925
- context "locale da", locale: :da do
1926
- it "sets errors on the IBAN" do
1927
- iban.valid_bank_code_format?
1928
- expect(iban.errors).to include(bank_code: "er ugyldig")
1929
- end
1930
- end
1931
-
1932
- context "locale sv", locale: :sv do
1933
- it "sets errors on the IBAN" do
1934
- iban.valid_bank_code_format?
1935
- expect(iban.errors).to include(bank_code: "är ogiltig")
1936
- end
1145
+ it "sets errors on the IBAN" do
1146
+ iban.valid_bank_code_format?
1147
+ expect(iban.errors).to include(bank_code: "format is invalid")
1937
1148
  end
1938
1149
  end
1939
1150
 
@@ -1972,81 +1183,9 @@ describe Ibandit::IBAN do
1972
1183
 
1973
1184
  it { is_expected.to eq(false) }
1974
1185
 
1975
- context "locale en", locale: :en do
1976
- it "sets errors on the IBAN" do
1977
- iban.valid_branch_code_format?
1978
- expect(iban.errors).to include(branch_code: "is invalid")
1979
- end
1980
- end
1981
-
1982
- context "locale fr", locale: :fr do
1983
- it "sets errors on the IBAN" do
1984
- iban.valid_branch_code_format?
1985
- expect(iban.errors).to include(branch_code: "n'est pas valide")
1986
- end
1987
- end
1988
-
1989
- context "locale de", locale: :de do
1990
- it "sets errors on the IBAN" do
1991
- iban.valid_branch_code_format?
1992
- expect(iban.errors).to include(branch_code: "ist ungültig")
1993
- end
1994
- end
1995
-
1996
- context "locale pt", locale: :pt do
1997
- it "sets errors on the IBAN" do
1998
- iban.valid_branch_code_format?
1999
- expect(iban.errors).to include(branch_code: "é inválido")
2000
- end
2001
- end
2002
-
2003
- context "locale es", locale: :es do
2004
- it "sets errors on the IBAN" do
2005
- iban.valid_branch_code_format?
2006
- expect(iban.errors).to include(branch_code: "no es válido")
2007
- end
2008
- end
2009
-
2010
- context "locale it", locale: :it do
2011
- it "sets errors on the IBAN" do
2012
- iban.valid_branch_code_format?
2013
- expect(iban.errors).to include(branch_code: "non è valido")
2014
- end
2015
- end
2016
-
2017
- context "locale nl", locale: :nl do
2018
- it "sets errors on the IBAN" do
2019
- iban.valid_branch_code_format?
2020
- expect(iban.errors).to include(branch_code: "is ongeldig")
2021
- end
2022
- end
2023
-
2024
- context "locale nb", locale: :nb do
2025
- it "sets errors on the IBAN" do
2026
- iban.valid_branch_code_format?
2027
- expect(iban.errors).to include(branch_code: "er ikke gyldig")
2028
- end
2029
- end
2030
-
2031
- context "locale sl", locale: :sl do
2032
- it "sets errors on the IBAN" do
2033
- iban.valid_branch_code_format?
2034
- expect(iban.errors).to include(branch_code: "ni veljavno")
2035
- end
2036
- end
2037
-
2038
- context "locale da", locale: :da do
2039
- it "sets errors on the IBAN" do
2040
- iban.valid_branch_code_format?
2041
- expect(iban.errors).to include(branch_code: "er ugyldig")
2042
- end
2043
- end
2044
-
2045
- context "locale sv", locale: :sv do
2046
- it "sets errors on the IBAN" do
2047
- iban.valid_branch_code_format?
2048
- expect(iban.errors).to include(branch_code: "är ogiltig")
2049
- end
1186
+ it "sets errors on the IBAN" do
1187
+ iban.valid_branch_code_format?
1188
+ expect(iban.errors).to include(branch_code: "format is invalid")
2050
1189
  end
2051
1190
  end
2052
1191
 
@@ -2084,81 +1223,9 @@ describe Ibandit::IBAN do
2084
1223
 
2085
1224
  it { is_expected.to eq(false) }
2086
1225
 
2087
- context "locale en", locale: :en do
2088
- it "sets errors on the IBAN" do
2089
- iban.valid_account_number_format?
2090
- expect(iban.errors).to include(account_number: "is invalid")
2091
- end
2092
- end
2093
-
2094
- context "locale fr", locale: :fr do
2095
- it "sets errors on the IBAN" do
2096
- iban.valid_account_number_format?
2097
- expect(iban.errors).to include(account_number: "n'est pas valide")
2098
- end
2099
- end
2100
-
2101
- context "locale de", locale: :de do
2102
- it "sets errors on the IBAN" do
2103
- iban.valid_account_number_format?
2104
- expect(iban.errors).to include(account_number: "ist ungültig")
2105
- end
2106
- end
2107
-
2108
- context "locale pt", locale: :pt do
2109
- it "sets errors on the IBAN" do
2110
- iban.valid_account_number_format?
2111
- expect(iban.errors).to include(account_number: "é inválido")
2112
- end
2113
- end
2114
-
2115
- context "locale es", locale: :es do
2116
- it "sets errors on the IBAN" do
2117
- iban.valid_account_number_format?
2118
- expect(iban.errors).to include(account_number: "no es válido")
2119
- end
2120
- end
2121
-
2122
- context "locale it", locale: :it do
2123
- it "sets errors on the IBAN" do
2124
- iban.valid_account_number_format?
2125
- expect(iban.errors).to include(account_number: "non è valido")
2126
- end
2127
- end
2128
-
2129
- context "locale nl", locale: :nl do
2130
- it "sets errors on the IBAN" do
2131
- iban.valid_account_number_format?
2132
- expect(iban.errors).to include(account_number: "is ongeldig")
2133
- end
2134
- end
2135
-
2136
- context "locale nb", locale: :nb do
2137
- it "sets errors on the IBAN" do
2138
- iban.valid_account_number_format?
2139
- expect(iban.errors).to include(account_number: "er ikke gyldig")
2140
- end
2141
- end
2142
-
2143
- context "locale sl", locale: :sl do
2144
- it "sets errors on the IBAN" do
2145
- iban.valid_account_number_format?
2146
- expect(iban.errors).to include(account_number: "ni veljavno")
2147
- end
2148
- end
2149
-
2150
- context "locale da", locale: :da do
2151
- it "sets errors on the IBAN" do
2152
- iban.valid_account_number_format?
2153
- expect(iban.errors).to include(account_number: "er ugyldig")
2154
- end
2155
- end
2156
-
2157
- context "locale sv", locale: :sv do
2158
- it "sets errors on the IBAN" do
2159
- iban.valid_account_number_format?
2160
- expect(iban.errors).to include(account_number: "är ogiltig")
2161
- end
1226
+ it "sets errors on the IBAN" do
1227
+ iban.valid_account_number_format?
1228
+ expect(iban.errors).to include(account_number: "format is invalid")
2162
1229
  end
2163
1230
  end
2164
1231
 
@@ -2217,54 +1284,8 @@ describe Ibandit::IBAN do
2217
1284
 
2218
1285
  it { is_expected.to be(false) }
2219
1286
 
2220
- context "locale en", locale: :en do
2221
- specify { expect(iban.errors).to include(bank_code: "is invalid") }
2222
- end
2223
-
2224
- context "locale fr", locale: :fr do
2225
- specify do
2226
- expect(iban.errors).to include(bank_code: "n'est pas valide")
2227
- end
2228
- end
2229
-
2230
- context "locale de", locale: :de do
2231
- specify do
2232
- expect(iban.errors).to include(bank_code: "ist ungültig")
2233
- end
2234
- end
2235
-
2236
- context "locale pt", locale: :pt do
2237
- specify { expect(iban.errors).to include(bank_code: "é inválido") }
2238
- end
2239
-
2240
- context "locale es", locale: :es do
2241
- specify { expect(iban.errors).to include(bank_code: "no es válido") }
2242
- end
2243
-
2244
- context "locale it", locale: :it do
2245
- specify { expect(iban.errors).to include(bank_code: "non è valido") }
2246
- end
2247
-
2248
- context "locale nl", locale: :nl do
2249
- specify { expect(iban.errors).to include(bank_code: "is ongeldig") }
2250
- end
2251
-
2252
- context "locale nb", locale: :nb do
2253
- specify do
2254
- expect(iban.errors).to include(bank_code: "er ikke gyldig")
2255
- end
2256
- end
2257
-
2258
- context "locale sl", locale: :sl do
2259
- specify { expect(iban.errors).to include(bank_code: "ni veljavno") }
2260
- end
2261
-
2262
- context "locale da", locale: :da do
2263
- specify { expect(iban.errors).to include(bank_code: "er ugyldig") }
2264
- end
2265
-
2266
- context "locale sv", locale: :sv do
2267
- specify { expect(iban.errors).to include(bank_code: "är ogiltig") }
1287
+ it "sets the errors on the IBAN" do
1288
+ expect(iban.errors).to include(bank_code: "did not pass modulus check")
2268
1289
  end
2269
1290
  end
2270
1291
 
@@ -2290,152 +1311,28 @@ describe Ibandit::IBAN do
2290
1311
 
2291
1312
  it { is_expected.to be(false) }
2292
1313
 
2293
- context "locale en", locale: :en do
2294
- specify do
2295
- expect(iban.errors).to include(branch_code: "is invalid")
2296
- end
1314
+ it "sets the errors on the IBAN" do
1315
+ expect(iban.errors).to include(branch_code: "did not pass modulus check")
2297
1316
  end
1317
+ end
2298
1318
 
2299
- context "locale fr", locale: :fr do
2300
- specify do
2301
- expect(iban.errors).to include(branch_code: "n'est pas valide")
2302
- end
2303
- end
1319
+ context "with an invalid account number" do
1320
+ let(:valid_bank_code) { true }
1321
+ let(:valid_branch_code) { true }
1322
+ let(:valid_account_number) { false }
2304
1323
 
2305
- context "locale de", locale: :de do
2306
- specify do
2307
- expect(iban.errors).to include(branch_code: "ist ungültig")
2308
- end
2309
- end
2310
-
2311
- context "locale pt", locale: :pt do
2312
- specify do
2313
- expect(iban.errors).to include(branch_code: "é inválido")
2314
- end
2315
- end
2316
-
2317
- context "locale es", locale: :es do
2318
- specify do
2319
- expect(iban.errors).to include(branch_code: "no es válido")
2320
- end
2321
- end
2322
-
2323
- context "locale it", locale: :it do
2324
- specify do
2325
- expect(iban.errors).to include(branch_code: "non è valido")
2326
- end
2327
- end
2328
-
2329
- context "locale nl", locale: :nl do
2330
- specify do
2331
- expect(iban.errors).to include(branch_code: "is ongeldig")
2332
- end
2333
- end
2334
-
2335
- context "locale nb", locale: :nb do
2336
- specify do
2337
- expect(iban.errors).to include(branch_code: "er ikke gyldig")
2338
- end
2339
- end
2340
-
2341
- context "locale sl", locale: :sl do
2342
- specify do
2343
- expect(iban.errors).to include(branch_code: "ni veljavno")
2344
- end
2345
- end
2346
-
2347
- context "locale da", locale: :da do
2348
- specify do
2349
- expect(iban.errors).to include(branch_code: "er ugyldig")
2350
- end
2351
- end
2352
-
2353
- context "locale sv", locale: :sv do
2354
- specify do
2355
- expect(iban.errors).to include(branch_code: "är ogiltig")
2356
- end
2357
- end
2358
- end
2359
-
2360
- context "with an invalid account number" do
2361
- let(:valid_bank_code) { true }
2362
- let(:valid_branch_code) { true }
2363
- let(:valid_account_number) { false }
2364
-
2365
- it "calls valid_account_number? with an IBAN object" do
2366
- expect(Ibandit.modulus_checker).
2367
- to receive(:valid_account_number?).
2368
- with(instance_of(described_class))
1324
+ it "calls valid_account_number? with an IBAN object" do
1325
+ expect(Ibandit.modulus_checker).
1326
+ to receive(:valid_account_number?).
1327
+ with(instance_of(described_class))
2369
1328
 
2370
1329
  iban.valid_local_modulus_check?
2371
1330
  end
2372
1331
 
2373
1332
  it { is_expected.to be(false) }
2374
1333
 
2375
- context "locale en", locale: :en do
2376
- specify do
2377
- expect(iban.errors).to include(account_number: "is invalid")
2378
- end
2379
- end
2380
-
2381
- context "locale fr", locale: :fr do
2382
- specify do
2383
- expect(iban.errors).to include(account_number: "n'est pas valide")
2384
- end
2385
- end
2386
-
2387
- context "locale de", locale: :de do
2388
- specify do
2389
- expect(iban.errors).to include(account_number: "ist ungültig")
2390
- end
2391
- end
2392
-
2393
- context "locale pt", locale: :pt do
2394
- specify do
2395
- expect(iban.errors).to include(account_number: "é inválido")
2396
- end
2397
- end
2398
-
2399
- context "locale es", locale: :es do
2400
- specify do
2401
- expect(iban.errors).to include(account_number: "no es válido")
2402
- end
2403
- end
2404
-
2405
- context "locale it", locale: :it do
2406
- specify do
2407
- expect(iban.errors).to include(account_number: "non è valido")
2408
- end
2409
- end
2410
-
2411
- context "locale nl", locale: :nl do
2412
- specify do
2413
- expect(iban.errors).to include(account_number: "is ongeldig")
2414
- end
2415
- end
2416
-
2417
- context "locale nb", locale: :nb do
2418
- specify do
2419
- expect(iban.errors).to include(account_number: "er ikke gyldig")
2420
- end
2421
- end
2422
-
2423
- context "locale sl", locale: :sl do
2424
- specify do
2425
- expect(iban.errors).to include(account_number: "ni veljavno")
2426
- end
2427
- end
2428
-
2429
- context "locale da", locale: :da do
2430
- specify do
2431
- expect(iban.errors).to include(account_number: "er ugyldig")
2432
- end
2433
- end
2434
-
2435
- context "locale sv", locale: :sv do
2436
- specify do
2437
- expect(iban.errors).to include(account_number: "är ogiltig")
2438
- end
1334
+ it "sets the errors on the IBAN" do
1335
+ expect(iban.errors).to include(account_number: "did not pass modulus check")
2439
1336
  end
2440
1337
  end
2441
1338
  end
@@ -2454,92 +1351,10 @@ describe Ibandit::IBAN do
2454
1351
 
2455
1352
  it { is_expected.to eq(false) }
2456
1353
 
2457
- context "locale en", locale: :en do
2458
- specify do
2459
- iban.supports_iban_determination?
2460
- expect(iban.errors).
2461
- to include(account_number: "does not support payments")
2462
- end
2463
- end
2464
-
2465
- context "locale fr", locale: :fr do
2466
- specify do
2467
- iban.supports_iban_determination?
2468
- expect(iban.errors).
2469
- to include(account_number: "ne prend pas en charge les paiements")
2470
- end
2471
- end
2472
-
2473
- context "locale de", locale: :de do
2474
- specify do
2475
- iban.supports_iban_determination?
2476
- expect(iban.errors).
2477
- to include(account_number: "unterstützt keine Zahlungen")
2478
- end
2479
- end
2480
-
2481
- context "locale pt", locale: :pt do
2482
- specify do
2483
- iban.supports_iban_determination?
2484
- expect(iban.errors).
2485
- to include(account_number: "não suporta pagamentos")
2486
- end
2487
- end
2488
-
2489
- context "locale es", locale: :es do
2490
- specify do
2491
- iban.supports_iban_determination?
2492
- expect(iban.errors).
2493
- to include(account_number: "no admite pagos")
2494
- end
2495
- end
2496
-
2497
- context "locale it", locale: :it do
2498
- specify do
2499
- iban.supports_iban_determination?
2500
- expect(iban.errors).
2501
- to include(account_number: "non supporta i pagamenti")
2502
- end
2503
- end
2504
-
2505
- context "locale nl", locale: :nl do
2506
- specify do
2507
- iban.supports_iban_determination?
2508
- expect(iban.errors).
2509
- to include(account_number: "ondersteunt geen betalingen")
2510
- end
2511
- end
2512
-
2513
- context "locale nb", locale: :nb do
2514
- specify do
2515
- iban.supports_iban_determination?
2516
- expect(iban.errors).
2517
- to include(account_number: "støtter ikke betalinger")
2518
- end
2519
- end
2520
-
2521
- context "locale sl", locale: :sl do
2522
- specify do
2523
- iban.supports_iban_determination?
2524
- expect(iban.errors).
2525
- to include(account_number: "ne podpira plačil")
2526
- end
2527
- end
2528
-
2529
- context "locale da", locale: :da do
2530
- specify do
2531
- iban.supports_iban_determination?
2532
- expect(iban.errors).
2533
- to include(account_number: "understøtter ikke betalinger")
2534
- end
2535
- end
2536
-
2537
- context "locale sv", locale: :sv do
2538
- specify do
2539
- iban.supports_iban_determination?
2540
- expect(iban.errors).
2541
- to include(account_number: "stödjer inte betalningar")
2542
- end
1354
+ it "sets the errors on the IBAN" do
1355
+ iban.supports_iban_determination?
1356
+ expect(iban.errors).
1357
+ to include(account_number: "does not support payments")
2543
1358
  end
2544
1359
  end
2545
1360
  end
@@ -2559,11 +1374,9 @@ describe Ibandit::IBAN do
2559
1374
 
2560
1375
  it { is_expected.to eq(false) }
2561
1376
 
2562
- context "locale en", locale: :en do
2563
- specify do
2564
- iban.valid_swedish_details?
2565
- expect(iban.errors).to eq(account_number: "is invalid")
2566
- end
1377
+ it "sets the errors on the IBAN" do
1378
+ iban.valid_swedish_details?
1379
+ expect(iban.errors).to eq(account_number: "length is invalid")
2567
1380
  end
2568
1381
  end
2569
1382
 
@@ -2578,12 +1391,13 @@ describe Ibandit::IBAN do
2578
1391
 
2579
1392
  it { is_expected.to eq(false) }
2580
1393
 
2581
- context "locale en", locale: :en do
2582
- specify do
2583
- iban.valid?
2584
- expect(iban.errors).to include(account_number: "is invalid")
2585
- expect(iban.errors).to_not include(:bank_code)
2586
- end
1394
+ it "sets the errors on the IBAN" do
1395
+ iban.valid?
1396
+ expect(iban.errors).to include(
1397
+ account_number: "bank code does not exist",
1398
+ format: "Unexpected format for a SE IBAN.",
1399
+ )
1400
+ expect(iban.errors).to_not include(:bank_code)
2587
1401
  end
2588
1402
  end
2589
1403
 
@@ -2598,11 +1412,9 @@ describe Ibandit::IBAN do
2598
1412
 
2599
1413
  it { is_expected.to eq(false) }
2600
1414
 
2601
- context "locale en", locale: :en do
2602
- specify do
2603
- iban.valid_swedish_details?
2604
- expect(iban.errors).to eq(account_number: "is invalid")
2605
- end
1415
+ it "sets the errors on the IBAN" do
1416
+ iban.valid_swedish_details?
1417
+ expect(iban.errors).to eq(account_number: "length is invalid")
2606
1418
  end
2607
1419
  end
2608
1420
  end
@@ -2630,11 +1442,9 @@ describe Ibandit::IBAN do
2630
1442
 
2631
1443
  it { is_expected.to eq(false) }
2632
1444
 
2633
- context "locale en", locale: :en do
2634
- specify do
2635
- iban.valid_swedish_details?
2636
- expect(iban.errors).to eq(branch_code: "is invalid")
2637
- end
1445
+ it "sets the errors on the IBAN" do
1446
+ iban.valid_swedish_details?
1447
+ expect(iban.errors).to eq(branch_code: "clearing code length is invalid")
2638
1448
  end
2639
1449
  end
2640
1450
 
@@ -2649,11 +1459,9 @@ describe Ibandit::IBAN do
2649
1459
 
2650
1460
  it { is_expected.to eq(false) }
2651
1461
 
2652
- context "locale en", locale: :en do
2653
- specify do
2654
- iban.valid_swedish_details?
2655
- expect(iban.errors).to eq(account_number: "is invalid")
2656
- end
1462
+ it "sets the errors on the IBAN" do
1463
+ iban.valid_swedish_details?
1464
+ expect(iban.errors).to eq(account_number: "serial number is invalid")
2657
1465
  end
2658
1466
  end
2659
1467
  end
@@ -2716,70 +1524,8 @@ describe Ibandit::IBAN do
2716
1524
 
2717
1525
  it { is_expected.to be(false) }
2718
1526
 
2719
- context "locale en", locale: :en do
2720
- specify do
2721
- expect(iban.errors).to include(branch_code: "is invalid")
2722
- end
2723
- end
2724
-
2725
- context "locale fr", locale: :fr do
2726
- specify do
2727
- expect(iban.errors).to include(branch_code: "n'est pas valide")
2728
- end
2729
- end
2730
-
2731
- context "locale de", locale: :de do
2732
- specify do
2733
- expect(iban.errors).to include(branch_code: "ist ungültig")
2734
- end
2735
- end
2736
-
2737
- context "locale pt", locale: :pt do
2738
- specify do
2739
- expect(iban.errors).to include(branch_code: "é inválido")
2740
- end
2741
- end
2742
-
2743
- context "locale es", locale: :es do
2744
- specify do
2745
- expect(iban.errors).to include(branch_code: "no es válido")
2746
- end
2747
- end
2748
-
2749
- context "locale it", locale: :it do
2750
- specify do
2751
- expect(iban.errors).to include(branch_code: "non è valido")
2752
- end
2753
- end
2754
-
2755
- context "locale nl", locale: :nl do
2756
- specify do
2757
- expect(iban.errors).to include(branch_code: "is ongeldig")
2758
- end
2759
- end
2760
-
2761
- context "locale nb", locale: :nb do
2762
- specify do
2763
- expect(iban.errors).to include(branch_code: "er ikke gyldig")
2764
- end
2765
- end
2766
-
2767
- context "locale sl", locale: :sl do
2768
- specify do
2769
- expect(iban.errors).to include(branch_code: "ni veljavno")
2770
- end
2771
- end
2772
-
2773
- context "locale da", locale: :da do
2774
- specify do
2775
- expect(iban.errors).to include(branch_code: "er ugyldig")
2776
- end
2777
- end
2778
-
2779
- context "locale sv", locale: :sv do
2780
- specify do
2781
- expect(iban.errors).to include(branch_code: "är ogiltig")
2782
- end
1527
+ it "sets the errors on the IBAN" do
1528
+ expect(iban.errors).to include(branch_code: "did not pass modulus check")
2783
1529
  end
2784
1530
  end
2785
1531
  end
@@ -2843,70 +1589,8 @@ describe Ibandit::IBAN do
2843
1589
 
2844
1590
  it { is_expected.to be(false) }
2845
1591
 
2846
- context "locale en", locale: :en do
2847
- specify do
2848
- expect(iban.errors).to include(branch_code: "is invalid")
2849
- end
2850
- end
2851
-
2852
- context "locale fr", locale: :fr do
2853
- specify do
2854
- expect(iban.errors).to include(branch_code: "n'est pas valide")
2855
- end
2856
- end
2857
-
2858
- context "locale de", locale: :de do
2859
- specify do
2860
- expect(iban.errors).to include(branch_code: "ist ungültig")
2861
- end
2862
- end
2863
-
2864
- context "locale pt", locale: :pt do
2865
- specify do
2866
- expect(iban.errors).to include(branch_code: "é inválido")
2867
- end
2868
- end
2869
-
2870
- context "locale es", locale: :es do
2871
- specify do
2872
- expect(iban.errors).to include(branch_code: "no es válido")
2873
- end
2874
- end
2875
-
2876
- context "locale it", locale: :it do
2877
- specify do
2878
- expect(iban.errors).to include(branch_code: "non è valido")
2879
- end
2880
- end
2881
-
2882
- context "locale nl", locale: :nl do
2883
- specify do
2884
- expect(iban.errors).to include(branch_code: "is ongeldig")
2885
- end
2886
- end
2887
-
2888
- context "locale nb", locale: :nb do
2889
- specify do
2890
- expect(iban.errors).to include(branch_code: "er ikke gyldig")
2891
- end
2892
- end
2893
-
2894
- context "locale sl", locale: :sl do
2895
- specify do
2896
- expect(iban.errors).to include(branch_code: "ni veljavno")
2897
- end
2898
- end
2899
-
2900
- context "locale da", locale: :da do
2901
- specify do
2902
- expect(iban.errors).to include(branch_code: "er ugyldig")
2903
- end
2904
- end
2905
-
2906
- context "locale sv", locale: :sv do
2907
- specify do
2908
- expect(iban.errors).to include(branch_code: "är ogiltig")
2909
- end
1592
+ it "sets the errors on the IBAN" do
1593
+ expect(iban.errors).to include(branch_code: "did not pass modulus check")
2910
1594
  end
2911
1595
  end
2912
1596
  end
@@ -2970,70 +1654,8 @@ describe Ibandit::IBAN do
2970
1654
 
2971
1655
  it { is_expected.to be(false) }
2972
1656
 
2973
- context "locale en", locale: :en do
2974
- specify do
2975
- expect(iban.errors).to include(branch_code: "is invalid")
2976
- end
2977
- end
2978
-
2979
- context "locale fr", locale: :fr do
2980
- specify do
2981
- expect(iban.errors).to include(branch_code: "n'est pas valide")
2982
- end
2983
- end
2984
-
2985
- context "locale de", locale: :de do
2986
- specify do
2987
- expect(iban.errors).to include(branch_code: "ist ungültig")
2988
- end
2989
- end
2990
-
2991
- context "locale pt", locale: :pt do
2992
- specify do
2993
- expect(iban.errors).to include(branch_code: "é inválido")
2994
- end
2995
- end
2996
-
2997
- context "locale es", locale: :es do
2998
- specify do
2999
- expect(iban.errors).to include(branch_code: "no es válido")
3000
- end
3001
- end
3002
-
3003
- context "locale it", locale: :it do
3004
- specify do
3005
- expect(iban.errors).to include(branch_code: "non è valido")
3006
- end
3007
- end
3008
-
3009
- context "locale nl", locale: :nl do
3010
- specify do
3011
- expect(iban.errors).to include(branch_code: "is ongeldig")
3012
- end
3013
- end
3014
-
3015
- context "locale nb", locale: :nb do
3016
- specify do
3017
- expect(iban.errors).to include(branch_code: "er ikke gyldig")
3018
- end
3019
- end
3020
-
3021
- context "locale sl", locale: :sl do
3022
- specify do
3023
- expect(iban.errors).to include(branch_code: "ni veljavno")
3024
- end
3025
- end
3026
-
3027
- context "locale da", locale: :da do
3028
- specify do
3029
- expect(iban.errors).to include(branch_code: "er ugyldig")
3030
- end
3031
- end
3032
-
3033
- context "locale sv", locale: :sv do
3034
- specify do
3035
- expect(iban.errors).to include(branch_code: "är ogiltig")
3036
- end
1657
+ it "sets the errors on the IBAN" do
1658
+ expect(iban.errors).to include(branch_code: "did not pass modulus check")
3037
1659
  end
3038
1660
  end
3039
1661
  end
@@ -3077,934 +1699,415 @@ describe Ibandit::IBAN do
3077
1699
  end
3078
1700
  end
3079
1701
 
3080
- context "for a valid Albanian IBAN" do
3081
- let(:iban_code) { "AL47 2121 1009 0000 0002 3569 8741" }
3082
-
3083
- it { is_expected.to be_valid }
3084
- end
3085
-
3086
- context "for a valid Andorran IBAN" do
3087
- let(:iban_code) { "AD12 0001 2030 2003 5910 0100" }
3088
-
3089
- it { is_expected.to be_valid }
3090
- end
3091
-
3092
- context "for a valid Austrian IBAN" do
3093
- let(:iban_code) { "AT61 1904 3002 3457 3201" }
3094
-
3095
- it { is_expected.to be_valid }
3096
- end
3097
-
3098
- context "for a valid Australian pseudo-IBAN" do
3099
- let(:iban_code) { "AUZZ123456123456789" }
3100
-
3101
- it { is_expected.to be_valid }
3102
- end
3103
-
3104
- context "for an invalid Australian pseudo-IBAN" do
3105
- let(:iban_code) { "AU99123456123456789" }
3106
-
3107
- it { is_expected.to_not be_valid }
3108
- end
3109
-
3110
- context "for a valid Azerbaijanian IBAN" do
3111
- let(:iban_code) { "AZ21 NABZ 0000 0000 1370 1000 1944" }
3112
-
3113
- it { is_expected.to be_valid }
3114
- end
3115
-
3116
- context "for an invalid Azerbaijanian IBAN" do
3117
- let(:iban_code) { "AZ91 NABZ 0000 0000 1370 1000 1944" }
3118
-
3119
- it { is_expected.to_not be_valid }
3120
- end
3121
-
3122
- context "for a valid Bahrainian IBAN" do
3123
- let(:iban_code) { "BH67 BMAG 0000 1299 1234 56" }
3124
-
3125
- it { is_expected.to be_valid }
3126
- end
3127
-
3128
- context "for an invalid Bahrainian IBAN" do
3129
- let(:iban_code) { "BH97 BMAG 0000 1299 1234 56" }
3130
-
3131
- it { is_expected.to_not be_valid }
3132
- end
3133
-
3134
- context "for a valid Belgian IBAN" do
3135
- let(:iban_code) { "BE68 5390 0754 7034" }
3136
-
3137
- it { is_expected.to be_valid }
3138
- end
3139
-
3140
- context "for an invalid Belgian IBAN" do
3141
- let(:iban_code) { "BE92 5100 0754 7061" }
3142
-
3143
- it { is_expected.to_not be_valid }
3144
- end
3145
-
3146
- context "for a valid Bosnian IBAN" do
3147
- let(:iban_code) { "BA39 1290 0794 0102 8494" }
3148
-
3149
- it { is_expected.to be_valid }
3150
- end
3151
-
3152
- context "for an invalid Bosnian IBAN" do
3153
- let(:iban_code) { "BA99 1290 0794 0102 8494" }
3154
-
3155
- it { is_expected.to_not be_valid }
3156
- end
3157
-
3158
- context "for a valid Bulgarian IBAN" do
3159
- let(:iban_code) { "BG80 BNBG 9661 1020 3456 78" }
3160
-
3161
- it { is_expected.to be_valid }
3162
- end
3163
-
3164
- context "for an invalid Bulgarian IBAN" do
3165
- let(:iban_code) { "BG90 BNBG 9661 1020 3456 78" }
3166
-
3167
- it { is_expected.to_not be_valid }
3168
- end
3169
-
3170
- context "for a valid Croatian IBAN" do
3171
- let(:iban_code) { "HR12 1001 0051 8630 0016 0" }
3172
-
3173
- it { is_expected.to be_valid }
3174
- end
3175
-
3176
- context "for an invalid Croatian IBAN" do
3177
- let(:iban_code) { "HR92 1001 0051 8630 0016 0" }
3178
-
3179
- it { is_expected.to_not be_valid }
3180
- end
3181
-
3182
- context "for a valid Costa Rican IBAN" do
3183
- let(:iban_code) { "CR05 0152 0200 1026 2840 66" }
3184
-
3185
- it { is_expected.to be_valid }
3186
- end
3187
-
3188
- context "for an invalid Costa Rican IBAN" do
3189
- let(:iban_code) { "CR05 0152 0200 1026 2840" }
3190
-
3191
- it { is_expected.to_not be_valid }
3192
- end
3193
-
3194
- context "for a valid Cypriot IBAN" do
3195
- let(:iban_code) { "CY17 0020 0128 0000 0012 0052 7600" }
3196
-
3197
- it { is_expected.to be_valid }
3198
- end
3199
-
3200
- context "for an invalid Cypriot IBAN" do
3201
- let(:iban_code) { "CY97 0020 0128 0000 0012 0052 7600" }
3202
-
3203
- it { is_expected.to_not be_valid }
3204
- end
3205
-
3206
- context "for a valid Czech IBAN" do
3207
- let(:iban_code) { "CZ65 0800 0000 1920 0014 5399" }
3208
-
3209
- it { is_expected.to be_valid }
3210
- end
3211
-
3212
- context "for an invalid Czech IBAN" do
3213
- let(:iban_code) { "CZ95 0800 0000 1920 0014 5399" }
3214
-
3215
- it { is_expected.to_not be_valid }
3216
- end
3217
-
3218
- context "for a valid Danish IBAN" do
3219
- let(:iban_code) { "DK50 0040 0440 1162 43" }
3220
-
3221
- it { is_expected.to be_valid }
3222
- end
3223
-
3224
- context "for an invalid Danish IBAN" do
3225
- let(:iban_code) { "DK90 0040 0440 1162 43" }
3226
-
3227
- it { is_expected.to_not be_valid }
3228
- end
3229
-
3230
- context "for a valid Dominican Republic IBAN" do
3231
- let(:iban_code) { "DO28 BAGR 0000 0001 2124 5361 1324" }
3232
-
3233
- it { is_expected.to be_valid }
3234
- end
3235
-
3236
- context "for an invalid Dominican Republic IBAN" do
3237
- let(:iban_code) { "DO28 BAGR 0000 0001 2124 5361" }
3238
-
3239
- it { is_expected.to_not be_valid }
3240
- end
3241
-
3242
- context "for a valid Estonian IBAN" do
3243
- let(:iban_code) { "EE38 2200 2210 2014 5685" }
3244
-
3245
- it { is_expected.to be_valid }
3246
- end
3247
-
3248
- context "for an invalid Estonian IBAN" do
3249
- let(:iban_code) { "EE98 2200 2210 2014 5685" }
3250
-
3251
- it { is_expected.to_not be_valid }
3252
- end
3253
-
3254
- context "for a valid Faroe Islands IBAN" do
3255
- let(:iban_code) { "FO97 5432 0388 8999 44" }
3256
-
3257
- it { is_expected.to be_valid }
3258
- end
3259
-
3260
- context "for an invalid Faroe Islands IBAN" do
3261
- let(:iban_code) { "FO27 5432 0388 8999 44" }
3262
-
3263
- it { is_expected.to_not be_valid }
3264
- end
3265
-
3266
- context "for a valid Finnish IBAN" do
3267
- let(:iban_code) { "FI21 1234 5600 0007 85" }
3268
-
3269
- it { is_expected.to be_valid }
3270
- end
3271
-
3272
- context "for an invalid Finnish IBAN" do
3273
- let(:iban_code) { "FI91 1234 5600 0007 85" }
3274
-
3275
- it { is_expected.to_not be_valid }
3276
- end
3277
-
3278
- context "for a valid French IBAN" do
3279
- let(:iban_code) { "FR14 2004 1010 0505 0001 3M02 606" }
3280
-
3281
- it { is_expected.to be_valid }
3282
- end
3283
-
3284
- context "for an invalid French IBAN" do
3285
- let(:iban_code) { "FR94 2004 1010 0505 0001 3M02 606" }
3286
-
3287
- it { is_expected.to_not be_valid }
3288
- end
3289
-
3290
- context "for a valid Georgian IBAN" do
3291
- let(:iban_code) { "GE29 NB00 0000 0101 9049 17" }
3292
-
3293
- it { is_expected.to be_valid }
3294
- end
3295
-
3296
- context "for an invalid Georgian IBAN" do
3297
- let(:iban_code) { "GE99 NB00 0000 0101 9049 17" }
3298
-
3299
- it { is_expected.to_not be_valid }
3300
- end
3301
-
3302
- context "for a valid German IBAN" do
3303
- let(:iban_code) { "DE89 3704 0044 0532 0130 00" }
3304
-
3305
- it { is_expected.to be_valid }
3306
- end
3307
-
3308
- context "for an invalid German IBAN" do
3309
- let(:iban_code) { "DE99 3704 0044 0532 0130 00" }
3310
-
3311
- it { is_expected.to_not be_valid }
3312
- end
3313
-
3314
- context "for a valid Gibraltan IBAN" do
3315
- let(:iban_code) { "GI75 NWBK 0000 0000 7099 453" }
3316
-
3317
- it { is_expected.to be_valid }
3318
- end
3319
-
3320
- context "for an invalid Gibraltan IBAN" do
3321
- let(:iban_code) { "GI95 NWBK 0000 0000 7099 453" }
3322
-
3323
- it { is_expected.to_not be_valid }
3324
- end
3325
-
3326
- context "for a valid Greek IBAN" do
3327
- let(:iban_code) { "GR16 0110 1250 0000 0001 2300 695" }
3328
-
3329
- it { is_expected.to be_valid }
3330
- end
3331
-
3332
- context "for an invalid Greek IBAN" do
3333
- let(:iban_code) { "GR96 0110 1250 0000 0001 2300 695" }
3334
-
3335
- it { is_expected.to_not be_valid }
3336
- end
3337
-
3338
- context "for a valid Greenland IBAN" do
3339
- let(:iban_code) { "GL56 0444 9876 5432 10" }
3340
-
3341
- it { is_expected.to be_valid }
3342
- end
3343
-
3344
- context "for an invalid Greenland IBAN" do
3345
- let(:iban_code) { "GL96 0444 9876 5432 10" }
3346
-
3347
- it { is_expected.to_not be_valid }
3348
- end
3349
-
3350
- context "for a valid Hungarian IBAN" do
3351
- let(:iban_code) { "HU42 1177 3016 1111 1018 0000 0000" }
3352
-
3353
- it { is_expected.to be_valid }
3354
- end
3355
-
3356
- context "for an invalid Hungarian IBAN" do
3357
- let(:iban_code) { "HU92 1177 3016 1111 1018 0000 0000" }
3358
-
3359
- it { is_expected.to_not be_valid }
3360
- end
3361
-
3362
- context "for a valid Icelandic IBAN" do
3363
- let(:iban_code) { "IS14 0159 2600 7654 5510 7303 39" }
3364
-
3365
- it { is_expected.to be_valid }
3366
- end
3367
-
3368
- context "for an invalid Icelandic IBAN" do
3369
- let(:iban_code) { "IS94 0159 2600 7654 5510 7303 39" }
3370
-
3371
- it { is_expected.to_not be_valid }
3372
- end
3373
-
3374
- context "for a valid Irish IBAN" do
3375
- let(:iban_code) { "IE29 AIBK 9311 5212 3456 78" }
3376
-
3377
- it { is_expected.to be_valid }
3378
- end
3379
-
3380
- context "for an invalid Irish IBAN" do
3381
- let(:iban_code) { "IE99 AIBK 9311 5212 3456 78" }
3382
-
3383
- it { is_expected.to_not be_valid }
3384
- end
3385
-
3386
- context "for a valid Israeli IBAN" do
3387
- let(:iban_code) { "IL62 0108 0000 0009 9999 999" }
3388
-
3389
- it { is_expected.to be_valid }
3390
- end
3391
-
3392
- context "for an invalid Israeli IBAN" do
3393
- let(:iban_code) { "IL92 0108 0000 0009 9999 999" }
3394
-
3395
- it { is_expected.to_not be_valid }
3396
- end
3397
-
3398
- context "for a valid Italian IBAN" do
3399
- let(:iban_code) { "IT60 X054 2811 1010 0000 0123 456" }
3400
-
3401
- it { is_expected.to be_valid }
3402
- end
3403
-
3404
- context "for an invalid Italian IBAN" do
3405
- let(:iban_code) { "IT90 S054 2811 1010 0000 0123 456" }
3406
-
3407
- it { is_expected.to_not be_valid }
3408
- end
3409
-
3410
- context "for a valid Jordanian IBAN" do
3411
- let(:iban_code) { "JO94 CBJO 0010 0000 0000 0131 0003 02" }
3412
-
3413
- it { is_expected.to be_valid }
3414
- end
3415
-
3416
- context "for an invalid Jordanian IBAN" do
3417
- let(:iban_code) { "JO24 CBJO 0010 0000 0000 0131 0003 02" }
3418
-
3419
- it { is_expected.to_not be_valid }
3420
- end
3421
-
3422
- context "for a valid Kuwaiti IBAN" do
3423
- let(:iban_code) { "KW81 CBKU 0000 0000 0000 1234 5601 01" }
3424
-
3425
- it { is_expected.to be_valid }
3426
- end
3427
-
3428
- context "for an invalid Kuwaiti IBAN" do
3429
- let(:iban_code) { "KW91 CBKU 0000 0000 0000 1234 5601 01" }
3430
-
3431
- it { is_expected.to_not be_valid }
3432
- end
3433
-
3434
- context "for a valid Latvian IBAN" do
3435
- let(:iban_code) { "LV80 BANK 0000 4351 9500 1" }
3436
-
3437
- it { is_expected.to be_valid }
3438
- end
3439
-
3440
- context "for an invalid Latvian IBAN" do
3441
- let(:iban_code) { "LV90 BANK 0000 4351 9500 1" }
3442
-
3443
- it { is_expected.to_not be_valid }
3444
- end
3445
-
3446
- context "for a valid Lebanese IBAN" do
3447
- let(:iban_code) { "LB62 0999 0000 0001 0019 0122 9114" }
3448
-
3449
- it { is_expected.to be_valid }
3450
- end
3451
-
3452
- context "for an invalid Lebanese IBAN" do
3453
- let(:iban_code) { "LB92 0999 0000 0001 0019 0122 9114" }
3454
-
3455
- it { is_expected.to_not be_valid }
3456
- end
3457
-
3458
- context "for a valid Liechtensteinian IBAN" do
3459
- let(:iban_code) { "LI21 0881 0000 2324 013A A" }
3460
-
3461
- it { is_expected.to be_valid }
3462
- end
3463
-
3464
- context "for an invalid Liechtensteinian IBAN" do
3465
- let(:iban_code) { "LI91 0881 0000 2324 013A A" }
3466
-
3467
- it { is_expected.to_not be_valid }
3468
- end
3469
-
3470
- context "for a valid Lithuanian IBAN" do
3471
- let(:iban_code) { "LT12 1000 0111 0100 1000" }
3472
-
3473
- it { is_expected.to be_valid }
3474
- end
3475
-
3476
- context "for an invalid Lithuanian IBAN" do
3477
- let(:iban_code) { "LT92 1000 0111 0100 1000" }
3478
-
3479
- it { is_expected.to_not be_valid }
3480
- end
3481
-
3482
- context "for a valid Luxembourgian IBAN" do
3483
- let(:iban_code) { "LU28 0019 4006 4475 0000" }
3484
-
3485
- it { is_expected.to be_valid }
3486
- end
3487
-
3488
- context "for an invalid Luxembourgian IBAN" do
3489
- let(:iban_code) { "LU98 0019 4006 4475 0000" }
3490
-
3491
- it { is_expected.to_not be_valid }
3492
- end
3493
-
3494
- context "for a valid Macedonian IBAN" do
3495
- let(:iban_code) { "MK072 5012 0000 0589 84" }
3496
-
3497
- it { is_expected.to be_valid }
3498
- end
3499
-
3500
- context "for an invalid Macedonian IBAN" do
3501
- let(:iban_code) { "MK972 5012 0000 0589 84" }
3502
-
3503
- it { is_expected.to_not be_valid }
3504
- end
3505
-
3506
- context "for a valid Maltese IBAN" do
3507
- let(:iban_code) { "MT84 MALT 0110 0001 2345 MTLC AST0 01S" }
3508
-
3509
- it { is_expected.to be_valid }
3510
- end
3511
-
3512
- context "for an invalid Maltese IBAN" do
3513
- let(:iban_code) { "MT94 MALT 0110 0001 2345 MTLC AST0 01S" }
3514
-
3515
- it { is_expected.to_not be_valid }
3516
- end
3517
-
3518
- context "for a valid Maurititanian IBAN" do
3519
- let(:iban_code) { "MU17 BOMM 0101 1010 3030 0200 000M UR" }
1702
+ RSpec.shared_examples "a country's IBAN" do |country_code|
1703
+ context "for #{country_code}" do
1704
+ context "with a valid iban" do
1705
+ let(:iban_code) { valid_iban }
3520
1706
 
3521
- it { is_expected.to be_valid }
3522
- end
1707
+ it { is_expected.to be_valid }
1708
+ end
3523
1709
 
3524
- context "for an invalid Maurititanian IBAN" do
3525
- let(:iban_code) { "MU97 BOMM 0101 1010 3030 0200 000M UR" }
1710
+ context "with an invalid iban" do
1711
+ let(:iban_code) { invalid_iban }
3526
1712
 
3527
- it { is_expected.to_not be_valid }
1713
+ it { is_expected.to_not be_valid }
1714
+ end
1715
+ end
3528
1716
  end
3529
1717
 
3530
- context "for a valid Moldovan IBAN" do
3531
- let(:iban_code) { "MD24 AG00 0225 1000 1310 4168" }
3532
-
3533
- it { is_expected.to be_valid }
1718
+ it_behaves_like "a country's IBAN", "AL" do
1719
+ let(:valid_iban) { "AL47 2121 1009 0000 0002 3569 8741" }
1720
+ let(:invalid_iban) { "ALXX47 2121 1009 0000 0002 3569 8741" }
3534
1721
  end
3535
1722
 
3536
- context "for an invalid Moldovan IBAN" do
3537
- let(:iban_code) { "MD94 AG00 0225 1000 1310 4168" }
3538
-
3539
- it { is_expected.to_not be_valid }
1723
+ it_behaves_like "a country's IBAN", "AD" do
1724
+ let(:valid_iban) { "AD12 0001 2030 2003 5910 0100" }
1725
+ let(:invalid_iban) { "ADXX12 0001 2030 2003 5910 0100" }
3540
1726
  end
3541
1727
 
3542
- context "for a valid Monocan IBAN" do
3543
- let(:iban_code) { "MC93 2005 2222 1001 1223 3M44 555" }
3544
-
3545
- it { is_expected.to be_valid }
1728
+ it_behaves_like "a country's IBAN", "AT" do
1729
+ let(:valid_iban) { "AT61 1904 3002 3457 3201" }
1730
+ let(:invalid_iban) { "ATXX61 1904 3002 3457 3201" }
3546
1731
  end
3547
1732
 
3548
- context "for an invalid Monocan IBAN" do
3549
- let(:iban_code) { "MC23 2005 2222 1001 1223 3M44 555" }
3550
-
3551
- it { is_expected.to_not be_valid }
1733
+ it_behaves_like "a country's IBAN", "AU" do
1734
+ let(:valid_iban) { "AUZZ123456123456789" }
1735
+ let(:invalid_iban) { "AUXXZZ123456123456789" }
3552
1736
  end
3553
1737
 
3554
- context "for a valid Montenegrian IBAN" do
3555
- let(:iban_code) { "ME25 5050 0001 2345 6789 51" }
3556
-
3557
- it { is_expected.to be_valid }
1738
+ it_behaves_like "a country's IBAN", "AZ" do
1739
+ let(:valid_iban) { "AZ21 NABZ 0000 0000 1370 1000 1944" }
1740
+ let(:invalid_iban) { "AZXX21 NABZ 0000 0000 1370 1000 1944" }
3558
1741
  end
3559
1742
 
3560
- context "for an invalid Montenegrian IBAN" do
3561
- let(:iban_code) { "ME95 5050 0001 2345 6789 51" }
3562
-
3563
- it { is_expected.to_not be_valid }
1743
+ it_behaves_like "a country's IBAN", "BH" do
1744
+ let(:valid_iban) { "BH67 BMAG 0000 1299 1234 56" }
1745
+ let(:invalid_iban) { "BHXX67 BMAG 0000 1299 1234 56" }
3564
1746
  end
3565
1747
 
3566
- context "for a valid Dutch IBAN" do
3567
- let(:iban_code) { "NL39 RABO 0300 0652 64" }
3568
-
3569
- it { is_expected.to be_valid }
1748
+ it_behaves_like "a country's IBAN", "BE" do
1749
+ let(:valid_iban) { "BE68 5390 0754 7034" }
1750
+ let(:invalid_iban) { "BEXX68 5390 0754 7034" }
3570
1751
  end
3571
1752
 
3572
- context "for an invalid Dutch IBAN" do
3573
- let(:iban_code) { "NL99 RABO 0300 0652 64" }
3574
-
3575
- it { is_expected.to_not be_valid }
1753
+ it_behaves_like "a country's IBAN", "BA" do
1754
+ let(:valid_iban) { "BA39 1290 0794 0102 8494" }
1755
+ let(:invalid_iban) { "BAXX39 1290 0794 0102 8494" }
3576
1756
  end
3577
1757
 
3578
- context "for a valid Norwegian IBAN" do
3579
- let(:iban_code) { "NO93 8601 1117 947" }
3580
-
3581
- it { is_expected.to be_valid }
1758
+ it_behaves_like "a country's IBAN", "BG" do
1759
+ let(:valid_iban) { "BG80 BNBG 9661 1020 3456 78" }
1760
+ let(:invalid_iban) { "BGXX80 BNBG 9661 1020 3456 78" }
3582
1761
  end
3583
1762
 
3584
- context "for an invalid Norwegian IBAN" do
3585
- let(:iban_code) { "NO23 8601 1117 947" }
3586
-
3587
- it { is_expected.to_not be_valid }
1763
+ it_behaves_like "a country's IBAN", "HR" do
1764
+ let(:valid_iban) { "HR12 1001 0051 8630 0016 0" }
1765
+ let(:invalid_iban) { "HRXX12 1001 0051 8630 0016 0" }
3588
1766
  end
3589
1767
 
3590
- context "for a valid New Zealand pseudo-IBAN" do
3591
- let(:iban_code) { "NZZZ5566667777777088" }
3592
-
3593
- it { is_expected.to be_valid }
1768
+ it_behaves_like "a country's IBAN", "CR" do
1769
+ let(:valid_iban) { "CR05 0152 0200 1026 2840 66" }
1770
+ let(:invalid_iban) { "CRXX05 0152 0200 1026 2840 66" }
3594
1771
  end
3595
1772
 
3596
- context "for an invalid New Zealand pseudo-IBAN" do
3597
- let(:iban_code) { "NZZZ55666677777770888" }
3598
-
3599
- it { is_expected.to_not be_valid }
1773
+ it_behaves_like "a country's IBAN", "CY" do
1774
+ let(:valid_iban) { "CY17 0020 0128 0000 0012 0052 7600" }
1775
+ let(:invalid_iban) { "CYXX17 0020 0128 0000 0012 0052 7600" }
3600
1776
  end
3601
1777
 
3602
- context "for a valid Pakistani IBAN" do
3603
- let(:iban_code) { "PK36 SCBL 0000 0011 2345 6702" }
3604
-
3605
- it { is_expected.to be_valid }
1778
+ it_behaves_like "a country's IBAN", "CZ" do
1779
+ let(:valid_iban) { "CZ65 0800 0000 1920 0014 5399" }
1780
+ let(:invalid_iban) { "CZXX65 0800 0000 1920 0014 5399" }
3606
1781
  end
3607
1782
 
3608
- context "for an invalid Pakistani IBAN" do
3609
- let(:iban_code) { "PK96 SCBL 0000 0011 2345 6702" }
3610
-
3611
- it { is_expected.to_not be_valid }
1783
+ it_behaves_like "a country's IBAN", "DK" do
1784
+ let(:valid_iban) { "DK50 0040 0440 1162 43" }
1785
+ let(:invalid_iban) { "DKXX50 0040 0440 1162 43" }
3612
1786
  end
3613
1787
 
3614
- context "for a valid Polish IBAN" do
3615
- let(:iban_code) { "PL60 1020 1026 0000 0422 7020 1111" }
3616
-
3617
- it { is_expected.to be_valid }
3618
- end
3619
-
3620
- context "for an invalid Polish IBAN" do
3621
- let(:iban_code) { "PL90 1020 1026 0000 0422 7020 1111" }
3622
-
3623
- it { is_expected.to_not be_valid }
1788
+ it_behaves_like "a country's IBAN", "DO" do
1789
+ let(:valid_iban) { "DO28 BAGR 0000 0001 2124 5361 1324" }
1790
+ let(:invalid_iban) { "DOXX28 BAGR 0000 0001 2124 5361 1324" }
3624
1791
  end
3625
1792
 
3626
- context "for a valid Palestinian IBAN" do
3627
- let(:iban_code) { "PS92 PALS 0000 0000 0400 1234 5670 2" }
3628
-
3629
- it { is_expected.to be_valid }
1793
+ it_behaves_like "a country's IBAN", "EE" do
1794
+ let(:valid_iban) { "EE38 2200 2210 2014 5685" }
1795
+ let(:invalid_iban) { "EEXX38 2200 2210 2014 5685" }
3630
1796
  end
3631
1797
 
3632
- context "for an invalid Palestinian IBAN" do
3633
- let(:iban_code) { "PS92 PALS 0000 0000 0400 1234 5670" }
3634
-
3635
- it { is_expected.to_not be_valid }
1798
+ it_behaves_like "a country's IBAN", "FO" do
1799
+ let(:valid_iban) { "FO97 5432 0388 8999 44" }
1800
+ let(:invalid_iban) { "FOXX97 5432 0388 8999 44" }
3636
1801
  end
3637
1802
 
3638
- context "for a valid Potuguese IBAN" do
3639
- let(:iban_code) { "PT50 0002 0123 1234 5678 9015 4" }
3640
-
3641
- it { is_expected.to be_valid }
1803
+ it_behaves_like "a country's IBAN", "FI" do
1804
+ let(:valid_iban) { "FI21 1234 5600 0007 85" }
1805
+ let(:invalid_iban) { "FIXX21 1234 5600 0007 85" }
3642
1806
  end
3643
1807
 
3644
- context "for an invalid Potuguese IBAN" do
3645
- let(:iban_code) { "PT90 0002 0123 1234 5678 9015 4" }
3646
-
3647
- it { is_expected.to_not be_valid }
1808
+ it_behaves_like "a country's IBAN", "FR" do
1809
+ let(:valid_iban) { "FR14 2004 1010 0505 0001 3M02 606" }
1810
+ let(:invalid_iban) { "FRXX14 2004 1010 0505 0001 3M02 606" }
3648
1811
  end
3649
1812
 
3650
- context "for a valid Qatari IBAN" do
3651
- let(:iban_code) { "QA58 DOHB 0000 1234 5678 90AB CDEF G" }
3652
-
3653
- it { is_expected.to be_valid }
1813
+ it_behaves_like "a country's IBAN", "GE" do
1814
+ let(:valid_iban) { "GE29 NB00 0000 0101 9049 17" }
1815
+ let(:invalid_iban) { "GEXX29 NB00 0000 0101 9049 17" }
3654
1816
  end
3655
1817
 
3656
- context "for an invalid Qatari IBAN" do
3657
- let(:iban_code) { "QA98 DOHB 0000 1234 5678 90AB CDEF G" }
3658
-
3659
- it { is_expected.to_not be_valid }
1818
+ it_behaves_like "a country's IBAN", "DE" do
1819
+ let(:valid_iban) { "DE89 3704 0044 0532 0130 00" }
1820
+ let(:invalid_iban) { "DEXX89 3704 0044 0532 0130 00" }
3660
1821
  end
3661
1822
 
3662
- context "for a valid Kosovan IBAN" do
3663
- let(:iban_code) { "XK05 1212 0123 4567 8906" }
3664
-
3665
- it { is_expected.to be_valid }
1823
+ it_behaves_like "a country's IBAN", "GI" do
1824
+ let(:valid_iban) { "GI75 NWBK 0000 0000 7099 453" }
1825
+ let(:invalid_iban) { "GIXX75 NWBK 0000 0000 7099 453" }
3666
1826
  end
3667
1827
 
3668
- context "for an invalid Kosovan IBAN" do
3669
- let(:iban_code) { "XK05 1212 0123 4567 890" }
3670
-
3671
- it { is_expected.to_not be_valid }
1828
+ it_behaves_like "a country's IBAN", "GR" do
1829
+ let(:valid_iban) { "GR16 0110 1250 0000 0001 2300 695" }
1830
+ let(:invalid_iban) { "GRXX16 0110 1250 0000 0001 2300 695" }
3672
1831
  end
3673
1832
 
3674
- context "for a valid Timor-Leste IBAN" do
3675
- let(:iban_code) { "TL38 0080 0123 4567 8910 157" }
3676
-
3677
- it { is_expected.to be_valid }
1833
+ it_behaves_like "a country's IBAN", "GL" do
1834
+ let(:valid_iban) { "GL56 0444 9876 5432 10" }
1835
+ let(:invalid_iban) { "GLXX56 0444 9876 5432 10" }
3678
1836
  end
3679
1837
 
3680
- context "for an invalid Timor-Leste IBAN" do
3681
- let(:iban_code) { "TL38 0080 0123 4567 8910" }
3682
-
3683
- it { is_expected.to_not be_valid }
1838
+ it_behaves_like "a country's IBAN", "HU" do
1839
+ let(:valid_iban) { "HU42 1177 3016 1111 1018 0000 0000" }
1840
+ let(:invalid_iban) { "HUXX42 1177 3016 1111 1018 0000 0000" }
3684
1841
  end
3685
1842
 
3686
- context "for a valid Romanian IBAN" do
3687
- let(:iban_code) { "RO49 AAAA 1B31 0075 9384 0000" }
3688
-
3689
- it { is_expected.to be_valid }
1843
+ it_behaves_like "a country's IBAN", "IS" do
1844
+ let(:valid_iban) { "IS14 0159 2600 7654 5510 7303 39" }
1845
+ let(:invalid_iban) { "ISXX14 0159 2600 7654 5510 7303 39" }
3690
1846
  end
3691
1847
 
3692
- context "for an invalid Romanian IBAN" do
3693
- let(:iban_code) { "RO99 AAAA 1B31 0075 9384 0000" }
3694
-
3695
- it { is_expected.to_not be_valid }
1848
+ it_behaves_like "a country's IBAN", "IE" do
1849
+ let(:valid_iban) { "IE29 AIBK 9311 5212 3456 78" }
1850
+ let(:invalid_iban) { "IEXX29 AIBK 9311 5212 3456 78" }
3696
1851
  end
3697
1852
 
3698
- context "for a valid San Marinian IBAN" do
3699
- let(:iban_code) { "SM86 U032 2509 8000 0000 0270 100" }
3700
-
3701
- it { is_expected.to be_valid }
1853
+ it_behaves_like "a country's IBAN", "IL" do
1854
+ let(:valid_iban) { "IL62 0108 0000 0009 9999 999" }
1855
+ let(:invalid_iban) { "ILXX62 0108 0000 0009 9999 999" }
3702
1856
  end
3703
1857
 
3704
- context "for an invalid San Marinian IBAN" do
3705
- let(:iban_code) { "SM96 U032 2509 8000 0000 0270 100" }
3706
-
3707
- it { is_expected.to_not be_valid }
1858
+ it_behaves_like "a country's IBAN", "IT" do
1859
+ let(:valid_iban) { "IT60 X054 2811 1010 0000 0123 456" }
1860
+ let(:invalid_iban) { "ITXX60 X054 2811 1010 0000 0123 456" }
3708
1861
  end
3709
1862
 
3710
- context "for a valid Saudi IBAN" do
3711
- let(:iban_code) { "SA03 8000 0000 6080 1016 7519" }
3712
-
3713
- it { is_expected.to be_valid }
1863
+ it_behaves_like "a country's IBAN", "JO" do
1864
+ let(:valid_iban) { "JO94 CBJO 0010 0000 0000 0131 0003 02" }
1865
+ let(:invalid_iban) { "JOXX94 CBJO 0010 0000 0000 0131 0003 02" }
3714
1866
  end
3715
1867
 
3716
- context "for an invalid Saudi IBAN" do
3717
- let(:iban_code) { "SA93 8000 0000 6080 1016 7519" }
3718
-
3719
- it { is_expected.to_not be_valid }
1868
+ it_behaves_like "a country's IBAN", "KW" do
1869
+ let(:valid_iban) { "KW81 CBKU 0000 0000 0000 1234 5601 01" }
1870
+ let(:invalid_iban) { "KWXX81 CBKU 0000 0000 0000 1234 5601 01" }
3720
1871
  end
3721
1872
 
3722
- context "for a valid Serbian IBAN" do
3723
- let(:iban_code) { "RS35 2600 0560 1001 6113 79" }
3724
-
3725
- it { is_expected.to be_valid }
1873
+ it_behaves_like "a country's IBAN", "LV" do
1874
+ let(:valid_iban) { "LV80 BANK 0000 4351 9500 1" }
1875
+ let(:invalid_iban) { "LVXX80 BANK 0000 4351 9500 1" }
3726
1876
  end
3727
1877
 
3728
- context "for an invalid Serbian IBAN" do
3729
- let(:iban_code) { "RS95 2600 0560 1001 6113 79" }
3730
-
3731
- it { is_expected.to_not be_valid }
1878
+ it_behaves_like "a country's IBAN", "LB" do
1879
+ let(:valid_iban) { "LB62 0999 0000 0001 0019 0122 9114" }
1880
+ let(:invalid_iban) { "LBXX62 0999 0000 0001 0019 0122 9114" }
3732
1881
  end
3733
1882
 
3734
- context "for a valid Slovakian IBAN" do
3735
- let(:iban_code) { "SK31 1200 0000 1987 4263 7541" }
3736
-
3737
- it { is_expected.to be_valid }
1883
+ it_behaves_like "a country's IBAN", "LI" do
1884
+ let(:valid_iban) { "LI21 0881 0000 2324 013A A" }
1885
+ let(:invalid_iban) { "LIXX21 0881 0000 2324 013A A" }
3738
1886
  end
3739
1887
 
3740
- context "for an invalid Slovakian IBAN" do
3741
- let(:iban_code) { "SK91 1200 0000 1987 4263 7541" }
3742
-
3743
- it { is_expected.to_not be_valid }
1888
+ it_behaves_like "a country's IBAN", "LT" do
1889
+ let(:valid_iban) { "LT12 1000 0111 0100 1000" }
1890
+ let(:invalid_iban) { "LTXX12 1000 0111 0100 1000" }
3744
1891
  end
3745
1892
 
3746
- context "for a valid Slovenian IBAN" do
3747
- let(:iban_code) { "SI56 1910 0000 0123 438" }
3748
-
3749
- it { is_expected.to be_valid }
1893
+ it_behaves_like "a country's IBAN", "LU" do
1894
+ let(:valid_iban) { "LU28 0019 4006 4475 0000" }
1895
+ let(:invalid_iban) { "LUXX28 0019 4006 4475 0000" }
3750
1896
  end
3751
1897
 
3752
- context "for an invalid Slovenian IBAN" do
3753
- let(:iban_code) { "SI96 1910 0000 0123 438" }
3754
-
3755
- it { is_expected.to_not be_valid }
1898
+ it_behaves_like "a country's IBAN", "MK" do
1899
+ let(:valid_iban) { "MK072 5012 0000 0589 84" }
1900
+ let(:invalid_iban) { "MKXX072 5012 0000 0589 84" }
3756
1901
  end
3757
1902
 
3758
- context "for a valid Spanish IBAN" do
3759
- let(:iban_code) { "ES80 2310 0001 1800 0001 2345" }
3760
-
3761
- it { is_expected.to be_valid }
1903
+ it_behaves_like "a country's IBAN", "MT" do
1904
+ let(:valid_iban) { "MT84 MALT 0110 0001 2345 MTLC AST0 01S" }
1905
+ let(:invalid_iban) { "MTXX84 MALT 0110 0001 2345 MTLC AST0 01S" }
3762
1906
  end
3763
1907
 
3764
- context "for an invalid Spanish IBAN" do
3765
- let(:iban_code) { "ES90 2310 0001 1800 0001 2345" }
3766
-
3767
- it { is_expected.to_not be_valid }
1908
+ it_behaves_like "a country's IBAN", "MU" do
1909
+ let(:valid_iban) { "MU17 BOMM 0101 1010 3030 0200 000M UR" }
1910
+ let(:invalid_iban) { "MUXX17 BOMM 0101 1010 3030 0200 000M UR" }
3768
1911
  end
3769
1912
 
3770
- context "for a valid Swedish IBAN" do
3771
- let(:iban_code) { "SE35 5000 0000 0549 1000 0003" }
3772
-
3773
- it { is_expected.to be_valid }
1913
+ it_behaves_like "a country's IBAN", "MD" do
1914
+ let(:valid_iban) { "MD24 AG00 0225 1000 1310 4168" }
1915
+ let(:invalid_iban) { "MDXX24 AG00 0225 1000 1310 4168" }
3774
1916
  end
3775
1917
 
3776
- context "for an invalid Swedish IBAN" do
3777
- let(:iban_code) { "SE95 5000 0000 0549 1000 0003" }
3778
-
3779
- it { is_expected.to_not be_valid }
1918
+ it_behaves_like "a country's IBAN", "MC" do
1919
+ let(:valid_iban) { "MC93 2005 2222 1001 1223 3M44 555" }
1920
+ let(:invalid_iban) { "MCXX93 2005 2222 1001 1223 3M44 555" }
3780
1921
  end
3781
1922
 
3782
- context "for a valid Swiss IBAN" do
3783
- let(:iban_code) { "CH93 0076 2011 6238 5295 7" }
3784
-
3785
- it { is_expected.to be_valid }
1923
+ it_behaves_like "a country's IBAN", "ME" do
1924
+ let(:valid_iban) { "ME25 5050 0001 2345 6789 51" }
1925
+ let(:invalid_iban) { "MEXX25 5050 0001 2345 6789 51" }
3786
1926
  end
3787
1927
 
3788
- context "for an invalid Swiss IBAN" do
3789
- let(:iban_code) { "CH23 0076 2011 6238 5295 7" }
3790
-
3791
- it { is_expected.to_not be_valid }
1928
+ it_behaves_like "a country's IBAN", "NL" do
1929
+ let(:valid_iban) { "NL39 RABO 0300 0652 64" }
1930
+ let(:invalid_iban) { "NLXX39 RABO 0300 0652 64" }
3792
1931
  end
3793
1932
 
3794
- context "for a valid Tunisian IBAN" do
3795
- let(:iban_code) { "TN59 1000 6035 1835 9847 8831" }
3796
-
3797
- it { is_expected.to be_valid }
1933
+ it_behaves_like "a country's IBAN", "NO" do
1934
+ let(:valid_iban) { "NO93 8601 1117 947" }
1935
+ let(:invalid_iban) { "NOXX93 8601 1117 947" }
3798
1936
  end
3799
1937
 
3800
- context "for an invalid Tunisian IBAN" do
3801
- let(:iban_code) { "TN99 1000 6035 1835 9847 8831" }
3802
-
3803
- it { is_expected.to_not be_valid }
1938
+ it_behaves_like "a country's IBAN", "NZ" do
1939
+ let(:valid_iban) { "NZZZ5566667777777088" }
1940
+ let(:invalid_iban) { "NZXXZZ5566667777777088" }
3804
1941
  end
3805
1942
 
3806
- context "for a valid Turkish IBAN" do
3807
- let(:iban_code) { "TR33 0006 1005 1978 6457 8413 26" }
3808
-
3809
- it { is_expected.to be_valid }
1943
+ it_behaves_like "a country's IBAN", "PK" do
1944
+ let(:valid_iban) { "PK36 SCBL 0000 0011 2345 6702" }
1945
+ let(:invalid_iban) { "PKXX36 SCBL 0000 0011 2345 6702" }
3810
1946
  end
3811
1947
 
3812
- context "for an invalid Turkish IBAN" do
3813
- let(:iban_code) { "TR93 0006 1005 1978 6457 8413 26" }
3814
-
3815
- it { is_expected.to_not be_valid }
1948
+ it_behaves_like "a country's IBAN", "PL" do
1949
+ let(:valid_iban) { "PL60 1020 1026 0000 0422 7020 1111" }
1950
+ let(:invalid_iban) { "PLXX60 1020 1026 0000 0422 7020 1111" }
3816
1951
  end
3817
1952
 
3818
- context "for a valid UAE IBAN" do
3819
- let(:iban_code) { "AE07 0331 2345 6789 0123 456" }
3820
-
3821
- it { is_expected.to be_valid }
1953
+ it_behaves_like "a country's IBAN", "PS" do
1954
+ let(:valid_iban) { "PS92 PALS 0000 0000 0400 1234 5670 2" }
1955
+ let(:invalid_iban) { "PSXX92 PALS 0000 0000 0400 1234 5670 2" }
3822
1956
  end
3823
1957
 
3824
- context "for an invalid UAE IBAN" do
3825
- let(:iban_code) { "AE97 0331 2345 6789 0123 456" }
3826
-
3827
- it { is_expected.to_not be_valid }
1958
+ it_behaves_like "a country's IBAN", "PT" do
1959
+ let(:valid_iban) { "PT50 0002 0123 1234 5678 9015 4" }
1960
+ let(:invalid_iban) { "PTXX50 0002 0123 1234 5678 9015 4" }
3828
1961
  end
3829
1962
 
3830
- context "for a valid UK IBAN" do
3831
- let(:iban_code) { "GB82 WEST 1234 5698 7654 32" }
3832
-
3833
- it { is_expected.to be_valid }
1963
+ it_behaves_like "a country's IBAN", "QA" do
1964
+ let(:valid_iban) { "QA58 DOHB 0000 1234 5678 90AB CDEF G" }
1965
+ let(:invalid_iban) { "QAXX58 DOHB 0000 1234 5678 90AB CDEF G" }
3834
1966
  end
3835
1967
 
3836
- context "for an invalid UK IBAN" do
3837
- let(:iban_code) { "GB92 WEST 1234 5698 7654 32" }
3838
-
3839
- it { is_expected.to_not be_valid }
1968
+ it_behaves_like "a country's IBAN", "XK" do
1969
+ let(:valid_iban) { "XK05 1212 0123 4567 8906" }
1970
+ let(:invalid_iban) { "XKXX05 1212 0123 4567 8906" }
3840
1971
  end
3841
1972
 
3842
- context "with a valid LC iban" do
3843
- let(:iban_code) { "LC55 HEMM 0001 0001 0012 0012 0002 3015" }
3844
-
3845
- it { is_expected.to be_valid }
1973
+ it_behaves_like "a country's IBAN", "TL" do
1974
+ let(:valid_iban) { "TL38 0080 0123 4567 8910 157" }
1975
+ let(:invalid_iban) { "TLXX38 0080 0123 4567 8910 157" }
3846
1976
  end
3847
1977
 
3848
- context "with an invalid LC iban" do
3849
- let(:iban_code) { "LC55 HEMM 0001 0001 0012 0012 0002" }
3850
-
3851
- it { is_expected.to_not be_valid }
1978
+ it_behaves_like "a country's IBAN", "RO" do
1979
+ let(:valid_iban) { "RO49 AAAA 1B31 0075 9384 0000" }
1980
+ let(:invalid_iban) { "ROXX49 AAAA 1B31 0075 9384 0000" }
3852
1981
  end
3853
1982
 
3854
- context "with a valid UA iban" do
3855
- let(:iban_code) { "UA21 3223 1300 0002 6007 2335 6600 1" }
3856
-
3857
- it { is_expected.to be_valid }
1983
+ it_behaves_like "a country's IBAN", "SM" do
1984
+ let(:valid_iban) { "SM86 U032 2509 8000 0000 0270 100" }
1985
+ let(:invalid_iban) { "SMXX86 U032 2509 8000 0000 0270 100" }
3858
1986
  end
3859
1987
 
3860
- context "with an invalid UA iban" do
3861
- let(:iban_code) { "UA21 3223 1300 0002 6007 2335 6600 " }
3862
-
3863
- it { is_expected.to_not be_valid }
1988
+ it_behaves_like "a country's IBAN", "SA" do
1989
+ let(:valid_iban) { "SA03 8000 0000 6080 1016 7519" }
1990
+ let(:invalid_iban) { "SAXX03 8000 0000 6080 1016 7519" }
3864
1991
  end
3865
1992
 
3866
- context "with a valid ST iban" do
3867
- let(:iban_code) { "ST23 0001 0001 0051 8453 1014 6" }
3868
-
3869
- it { is_expected.to be_valid }
1993
+ it_behaves_like "a country's IBAN", "RS" do
1994
+ let(:valid_iban) { "RS35 2600 0560 1001 6113 79" }
1995
+ let(:invalid_iban) { "RSXX35 2600 0560 1001 6113 79" }
3870
1996
  end
3871
1997
 
3872
- context "with an invalid ST iban" do
3873
- let(:iban_code) { "ST23 0001 0001 0051 8453 1014" }
3874
-
3875
- it { is_expected.to_not be_valid }
1998
+ it_behaves_like "a country's IBAN", "SK" do
1999
+ let(:valid_iban) { "SK31 1200 0000 1987 4263 7541" }
2000
+ let(:invalid_iban) { "SKXX31 1200 0000 1987 4263 7541" }
3876
2001
  end
3877
2002
 
3878
- context "with a valid SC iban" do
3879
- let(:iban_code) { "SC18 SSCB 1101 0000 0000 0000 1497 USD" }
3880
-
3881
- it { is_expected.to be_valid }
2003
+ it_behaves_like "a country's IBAN", "SI" do
2004
+ let(:valid_iban) { "SI56 1910 0000 0123 438" }
2005
+ let(:invalid_iban) { "SIXX56 1910 0000 0123 438" }
3882
2006
  end
3883
2007
 
3884
- context "with an invalid SC iban" do
3885
- let(:iban_code) { "SC18 SSCB 1101 0000 0000 0000 USD" }
3886
-
3887
- it { is_expected.to_not be_valid }
2008
+ it_behaves_like "a country's IBAN", "ES" do
2009
+ let(:valid_iban) { "ES80 2310 0001 1800 0001 2345" }
2010
+ let(:invalid_iban) { "ESXX80 2310 0001 1800 0001 2345" }
3888
2011
  end
3889
2012
 
3890
- context "with a valid IQ iban" do
3891
- let(:iban_code) { "IQ98 NBIQ 8501 2345 6789 012" }
3892
-
3893
- it { is_expected.to be_valid }
2013
+ it_behaves_like "a country's IBAN", "SE" do
2014
+ let(:valid_iban) { "SE35 5000 0000 0549 1000 0003" }
2015
+ let(:invalid_iban) { "SEXX35 5000 0000 0549 1000 0003" }
3894
2016
  end
3895
2017
 
3896
- context "with an invalid IQ iban" do
3897
- let(:iban_code) { "IQ98 NBIQ 8501 2345 6789" }
3898
-
3899
- it { is_expected.to_not be_valid }
2018
+ it_behaves_like "a country's IBAN", "CH" do
2019
+ let(:valid_iban) { "CH93 0076 2011 6238 5295 7" }
2020
+ let(:invalid_iban) { "CHXX93 0076 2011 6238 5295 7" }
3900
2021
  end
3901
2022
 
3902
- context "with a valid SV iban" do
3903
- let(:iban_code) { "SV 62 CENR 00000000000000700025" }
3904
-
3905
- it { is_expected.to be_valid }
2023
+ it_behaves_like "a country's IBAN", "TN" do
2024
+ let(:valid_iban) { "TN59 1000 6035 1835 9847 8831" }
2025
+ let(:invalid_iban) { "TNXX59 1000 6035 1835 9847 8831" }
3906
2026
  end
3907
2027
 
3908
- context "with an invalid SV iban" do
3909
- let(:iban_code) { "SV 62 CENR 00000000000000700" }
3910
-
3911
- it { is_expected.to_not be_valid }
2028
+ it_behaves_like "a country's IBAN", "TR" do
2029
+ let(:valid_iban) { "TR33 0006 1005 1978 6457 8413 26" }
2030
+ let(:invalid_iban) { "TRXX33 0006 1005 1978 6457 8413 26" }
3912
2031
  end
3913
2032
 
3914
- context "with a valid BY iban" do
3915
- let(:iban_code) { "BY13 NBRB 3600 9000 0000 2Z00 AB00" }
3916
-
3917
- it { is_expected.to be_valid }
2033
+ it_behaves_like "a country's IBAN", "AE" do
2034
+ let(:valid_iban) { "AE07 0331 2345 6789 0123 456" }
2035
+ let(:invalid_iban) { "AEXX07 0331 2345 6789 0123 456" }
3918
2036
  end
3919
2037
 
3920
- context "with an invalid BY iban" do
3921
- let(:iban_code) { "BY13 NBRB 3600 9000 0000 2Z00" }
3922
-
3923
- it { is_expected.to_not be_valid }
2038
+ it_behaves_like "a country's IBAN", "GB" do
2039
+ let(:valid_iban) { "GB82 WEST 1234 5698 7654 32" }
2040
+ let(:invalid_iban) { "GBXX82 WEST 1234 5698 7654 32" }
3924
2041
  end
3925
2042
 
3926
- context "with a valid VA iban" do
3927
- let(:iban_code) { "VA59 001 1230 0001 2345 678" }
3928
-
3929
- it { is_expected.to be_valid }
2043
+ it_behaves_like "a country's IBAN", "LC" do
2044
+ let(:valid_iban) { "LC55 HEMM 0001 0001 0012 0012 0002 3015" }
2045
+ let(:invalid_iban) { "LCXX55 HEMM 0001 0001 0012 0012 0002 3015" }
3930
2046
  end
3931
2047
 
3932
- context "with an invalid VA iban" do
3933
- let(:iban_code) { "VA59 001 1230 0001 2345" }
3934
-
3935
- it { is_expected.to_not be_valid }
2048
+ it_behaves_like "a country's IBAN", "UA" do
2049
+ let(:valid_iban) { "UA21 3223 1300 0002 6007 2335 6600 1" }
2050
+ let(:invalid_iban) { "UAXX21 3223 1300 0002 6007 2335 6600 1" }
3936
2051
  end
3937
2052
 
3938
- context "with a valid EG iban" do
3939
- let(:iban_code) { "EG380019000500000000263180002" }
3940
-
3941
- it { is_expected.to be_valid }
2053
+ it_behaves_like "a country's IBAN", "ST" do
2054
+ let(:valid_iban) { "ST23 0001 0001 0051 8453 1014 6" }
2055
+ let(:invalid_iban) { "STXX23 0001 0001 0051 8453 1014 6" }
3942
2056
  end
3943
2057
 
3944
- context "with an invalid EG iban" do
3945
- let(:iban_code) { "EG3800190005000000002631800" }
3946
-
3947
- it { is_expected.to_not be_valid }
2058
+ it_behaves_like "a country's IBAN", "SC" do
2059
+ let(:valid_iban) { "SC18 SSCB 1101 0000 0000 0000 1497 USD" }
2060
+ let(:invalid_iban) { "SCXX18 SSCB 1101 0000 0000 0000 1497 USD" }
3948
2061
  end
3949
2062
 
3950
- context "with a valid LY iban" do
3951
- let(:iban_code) { "LY83002048000020100120361" }
3952
-
3953
- it { is_expected.to be_valid }
2063
+ it_behaves_like "a country's IBAN", "IQ" do
2064
+ let(:valid_iban) { "IQ98 NBIQ 8501 2345 6789 012" }
2065
+ let(:invalid_iban) { "IQXX98 NBIQ 8501 2345 6789 012" }
3954
2066
  end
3955
2067
 
3956
- context "with an invalid LY iban" do
3957
- let(:iban_code) { "LY830020480000120361" }
3958
-
3959
- it { is_expected.to_not be_valid }
2068
+ it_behaves_like "a country's IBAN", "SV" do
2069
+ let(:valid_iban) { "SV 62 CENR 00000000000000700025" }
2070
+ let(:invalid_iban) { "SVXX 62 CENR 00000000000000700025" }
3960
2071
  end
3961
2072
 
3962
- context "with a valid SD iban" do
3963
- let(:iban_code) { "SD2129010501234001" }
3964
-
3965
- it { is_expected.to be_valid }
2073
+ it_behaves_like "a country's IBAN", "BY" do
2074
+ let(:valid_iban) { "BY13 NBRB 3600 9000 0000 2Z00 AB00" }
2075
+ let(:invalid_iban) { "BYXX13 NBRB 3600 9000 0000 2Z00 AB00" }
3966
2076
  end
3967
2077
 
3968
- context "with an invalid SD iban" do
3969
- let(:iban_code) { "SD21290104001" }
3970
-
3971
- it { is_expected.to_not be_valid }
2078
+ it_behaves_like "a country's IBAN", "VA" do
2079
+ let(:valid_iban) { "VA59 001 1230 0001 2345 678" }
2080
+ let(:invalid_iban) { "VAXX59 001 1230 0001 2345 678" }
3972
2081
  end
3973
2082
 
3974
- context "with a valid BI iban" do
3975
- let(:iban_code) { "BI4210000100010000332045181" }
3976
-
3977
- it { is_expected.to be_valid }
2083
+ it_behaves_like "a country's IBAN", "EG" do
2084
+ let(:valid_iban) { "EG380019000500000000263180002" }
2085
+ let(:invalid_iban) { "EGXX380019000500000000263180002" }
3978
2086
  end
3979
2087
 
3980
- context "with an invalid BI iban" do
3981
- let(:iban_code) { "BI4210000100000332045181" }
3982
-
3983
- it { is_expected.to_not be_valid }
2088
+ it_behaves_like "a country's IBAN", "LY" do
2089
+ let(:valid_iban) { "LY83002048000020100120361" }
2090
+ let(:invalid_iban) { "LYXX83002048000020100120361" }
3984
2091
  end
3985
2092
 
3986
- context "with a valid DJ iban" do
3987
- let(:iban_code) { "DJ2100010000000154000100186" }
3988
-
3989
- it { is_expected.to be_valid }
2093
+ it_behaves_like "a country's IBAN", "SD" do
2094
+ let(:valid_iban) { "SD2129010501234001" }
2095
+ let(:invalid_iban) { "SDXX2129010501234001" }
3990
2096
  end
3991
2097
 
3992
- context "with an invalid DJ iban" do
3993
- let(:iban_code) { "DJ2100010000000000100186" }
3994
-
3995
- it { is_expected.to_not be_valid }
2098
+ it_behaves_like "a country's IBAN", "BI" do
2099
+ let(:valid_iban) { "BI4210000100010000332045181" }
2100
+ let(:invalid_iban) { "BIXX4210000100010000332045181" }
3996
2101
  end
3997
2102
 
3998
- context "with a valid RU iban" do
3999
- let(:iban_code) { "RU0204452560040702810412345678901" }
4000
-
4001
- it { is_expected.to be_valid }
2103
+ it_behaves_like "a country's IBAN", "DJ" do
2104
+ let(:valid_iban) { "DJ2100010000000154000100186" }
2105
+ let(:invalid_iban) { "DJXX2100010000000154000100186" }
4002
2106
  end
4003
2107
 
4004
- context "with an invalid RU iban" do
4005
- let(:iban_code) { "RU1704452522540817810538091310419" }
4006
-
4007
- it { is_expected.to_not be_valid }
2108
+ it_behaves_like "a country's IBAN", "RU" do
2109
+ let(:valid_iban) { "RU0204452560040702810412345678901" }
2110
+ let(:invalid_iban) { "RUXX0204452560040702810412345678901" }
4008
2111
  end
4009
2112
  end
4010
2113