ibandit 0.11.19 → 0.11.20

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,6 +5,7 @@ describe Ibandit::IBANSplitter do
5
5
 
6
6
  context "with a valid IBAN" do
7
7
  let(:iban_code) { "GB82WEST12345698765432" }
8
+
8
9
  its([:country_code]) { is_expected.to eq("GB") }
9
10
  its([:check_digits]) { is_expected.to eq("82") }
10
11
  its([:bank_code]) { is_expected.to eq("WEST") }
@@ -14,6 +15,7 @@ describe Ibandit::IBANSplitter do
14
15
 
15
16
  context "with nil" do
16
17
  let(:iban_code) { nil }
18
+
17
19
  its([:country_code]) { is_expected.to eq(nil) }
18
20
  its([:check_digits]) { is_expected.to eq(nil) }
19
21
  its([:bank_code]) { is_expected.to eq(nil) }
@@ -23,6 +25,7 @@ describe Ibandit::IBANSplitter do
23
25
 
24
26
  context "with an empty string" do
25
27
  let(:iban_code) { "" }
28
+
26
29
  its([:country_code]) { is_expected.to eq(nil) }
27
30
  its([:check_digits]) { is_expected.to eq(nil) }
28
31
  its([:bank_code]) { is_expected.to eq(nil) }
@@ -32,6 +35,7 @@ describe Ibandit::IBANSplitter do
32
35
 
33
36
  context "with an invalid length IBAN" do
34
37
  let(:iban_code) { "MC9320052222100112233M445" }
38
+
35
39
  its([:country_code]) { is_expected.to eq("MC") }
36
40
  its([:check_digits]) { is_expected.to eq(nil) }
37
41
  its([:bank_code]) { is_expected.to eq(nil) }
@@ -2,6 +2,7 @@ require "spec_helper"
2
2
 
3
3
  describe Ibandit::LocalDetailsCleaner do
4
4
  subject(:cleaned) { described_class.clean(local_details) }
5
+
5
6
  let(:local_details) do
6
7
  {
7
8
  country_code: country_code,
@@ -30,6 +31,7 @@ describe Ibandit::LocalDetailsCleaner do
30
31
 
31
32
  context "with an unsupported country code" do
32
33
  let(:country_code) { "FU" }
34
+
33
35
  it { is_expected.to eq(local_details_with_swift) }
34
36
  end
35
37
 
@@ -42,36 +44,43 @@ describe Ibandit::LocalDetailsCleaner do
42
44
 
43
45
  context "with an account number which needs zero-padding" do
44
46
  let(:account_number) { "234573201" }
47
+
45
48
  its([:account_number]) { is_expected.to eq("00234573201") }
46
49
  end
47
50
 
48
51
  context "with an account number under 4 digits" do
49
52
  let(:account_number) { "123" }
53
+
50
54
  its([:account_number]) { is_expected.to eq("123") }
51
55
  end
52
56
 
53
57
  context "with a long account number" do
54
58
  let(:account_number) { "234573201999" }
59
+
55
60
  it { is_expected.to eq(local_details_with_swift) }
56
61
  end
57
62
 
58
63
  context "without an account number" do
59
64
  let(:account_number) { nil }
65
+
60
66
  it { is_expected.to eq(local_details_with_swift) }
61
67
  end
62
68
 
63
69
  context "with a short bank code" do
64
70
  let(:bank_code) { "1904" }
71
+
65
72
  it { is_expected.to eq(local_details_with_swift) }
66
73
  end
67
74
 
68
75
  context "with a long bank code" do
69
76
  let(:bank_code) { "190430" }
77
+
70
78
  it { is_expected.to eq(local_details_with_swift) }
71
79
  end
72
80
 
73
81
  context "without a bank code" do
74
82
  let(:bank_code) { nil }
83
+
75
84
  it { is_expected.to eq(local_details_with_swift) }
76
85
  end
77
86
  end
@@ -107,12 +116,14 @@ describe Ibandit::LocalDetailsCleaner do
107
116
 
108
117
  context "with dashes" do
109
118
  let(:account_number) { "510-0075470-61" }
119
+
110
120
  its([:bank_code]) { is_expected.to eq("510") }
111
121
  its([:account_number]) { is_expected.to eq("510007547061") }
112
122
  end
113
123
 
114
124
  context "without an account number" do
115
125
  let(:account_number) { nil }
126
+
116
127
  it { is_expected.to eq(local_details_with_swift) }
117
128
  end
118
129
  end
@@ -127,20 +138,35 @@ describe Ibandit::LocalDetailsCleaner do
127
138
 
128
139
  context "without an account number" do
129
140
  let(:account_number) { nil }
141
+
130
142
  it { is_expected.to eq(local_details_with_swift) }
131
143
  end
132
144
 
133
145
  context "without a branch code" do
134
146
  let(:branch_code) { nil }
147
+
135
148
  it { is_expected.to eq(local_details_with_swift) }
136
149
  end
137
150
 
138
151
  context "without a bank code" do
139
152
  let(:bank_code) { nil }
153
+
140
154
  it { is_expected.to eq(local_details_with_swift) }
141
155
  end
142
156
  end
143
157
 
158
+ context "Canada" do
159
+ let(:country_code) { "CA" }
160
+ let(:account_number) { "0123456" }
161
+ let(:bank_code) { "0036" }
162
+ let(:branch_code) { "00063" }
163
+
164
+ its([:account_number]) { is_expected.to eq("000000123456") }
165
+ its([:country_code]) { is_expected.to eq(country_code) }
166
+ its([:bank_code]) { is_expected.to eq("0036") }
167
+ its([:branch_code]) { is_expected.to eq("00063") }
168
+ end
169
+
144
170
  context "Cyprus" do
145
171
  let(:country_code) { "CY" }
146
172
  let(:account_number) { "0000001200527600" }
@@ -151,33 +177,39 @@ describe Ibandit::LocalDetailsCleaner do
151
177
 
152
178
  context "with a short account number" do
153
179
  let(:account_number) { "1200527600" }
180
+
154
181
  its([:account_number]) { is_expected.to eq("0000001200527600") }
155
182
  end
156
183
 
157
184
  context "with a too-short account number" do
158
185
  let(:account_number) { "123456" }
186
+
159
187
  its([:account_number]) { is_expected.to eq(account_number) }
160
188
  end
161
189
 
162
190
  context "with a long account number" do
163
191
  let(:account_number) { "00000001200527600" }
192
+
164
193
  it { is_expected.to eq(local_details_with_swift) }
165
194
  end
166
195
 
167
196
  context "without an account number" do
168
197
  let(:account_number) { nil }
198
+
169
199
  it { is_expected.to eq(local_details_with_swift) }
170
200
  end
171
201
 
172
202
  context "with the branch code in the bank code field" do
173
203
  let(:bank_code) { "002 00128" }
174
204
  let(:branch_code) { nil }
205
+
175
206
  its([:bank_code]) { is_expected.to eq("002") }
176
207
  its([:branch_code]) { is_expected.to eq("00128") }
177
208
  end
178
209
 
179
210
  context "without a bank code" do
180
211
  let(:bank_code) { nil }
212
+
181
213
  it { is_expected.to eq(local_details_with_swift) }
182
214
  end
183
215
  end
@@ -192,23 +224,27 @@ describe Ibandit::LocalDetailsCleaner do
192
224
  context "with an account number prefix" do
193
225
  let(:prefix) { "000019" }
194
226
  let(:account_number) { "2000145399" }
227
+
195
228
  before { local_details.merge!(account_number_prefix: prefix) }
196
229
 
197
230
  its([:account_number]) { is_expected.to eq("0000192000145399") }
198
231
 
199
232
  context "which needs zero-padding" do
200
233
  let(:prefix) { "19" }
234
+
201
235
  its([:account_number]) { is_expected.to eq("0000192000145399") }
202
236
  end
203
237
  end
204
238
 
205
239
  context "without a bank code" do
206
240
  let(:bank_code) { nil }
241
+
207
242
  it { is_expected.to eq(local_details_with_swift) }
208
243
  end
209
244
 
210
245
  context "without an account number" do
211
246
  let(:account_number) { nil }
247
+
212
248
  it { is_expected.to eq(local_details_with_swift) }
213
249
  end
214
250
  end
@@ -222,22 +258,26 @@ describe Ibandit::LocalDetailsCleaner do
222
258
 
223
259
  context "without a bank code" do
224
260
  let(:bank_code) { nil }
261
+
225
262
  it { is_expected.to eq(local_details_with_swift) }
226
263
  end
227
264
 
228
265
  context "without an account number" do
229
266
  let(:account_number) { nil }
267
+
230
268
  it { is_expected.to eq(local_details_with_swift) }
231
269
  end
232
270
 
233
271
  context "with an excessively short account number" do
234
272
  let(:account_number) { "666" }
273
+
235
274
  its([:account_number]) { is_expected.to eq(account_number) }
236
275
  end
237
276
 
238
277
  context "with a pseudo account number" do
239
278
  let(:bank_code) { "37080040" }
240
279
  let(:account_number) { "111" }
280
+
241
281
  its([:bank_code]) { is_expected.to eq(bank_code) }
242
282
  its([:account_number]) { is_expected.to eq("0215022000") }
243
283
  end
@@ -245,6 +285,7 @@ describe Ibandit::LocalDetailsCleaner do
245
285
  context "with unsupported account details" do
246
286
  let(:account_number) { "7955791111" }
247
287
  let(:bank_code) { "20000000" }
288
+
248
289
  it { is_expected.to eq(local_details_with_swift) }
249
290
  end
250
291
  end
@@ -285,6 +326,7 @@ describe Ibandit::LocalDetailsCleaner do
285
326
 
286
327
  context "without an account number" do
287
328
  let(:account_number) { nil }
329
+
288
330
  it { is_expected.to eq(local_details_with_swift) }
289
331
  end
290
332
  end
@@ -298,12 +340,14 @@ describe Ibandit::LocalDetailsCleaner do
298
340
 
299
341
  context "with an account number that needs translating" do
300
342
  let(:account_number) { "111020145685" }
343
+
301
344
  its([:bank_code]) { is_expected.to eq("22") }
302
345
  its([:account_number]) { is_expected.to eq("00111020145685") }
303
346
  end
304
347
 
305
348
  context "without an account number" do
306
349
  let(:account_number) { nil }
350
+
307
351
  it { is_expected.to eq(local_details_with_swift) }
308
352
  end
309
353
  end
@@ -328,11 +372,13 @@ describe Ibandit::LocalDetailsCleaner do
328
372
 
329
373
  context "with spaces in the account number" do
330
374
  let(:account_number) { "18 0000012345" }
375
+
331
376
  its([:account_number]) { is_expected.to eq("180000012345") }
332
377
  end
333
378
 
334
379
  context "without an account number" do
335
380
  let(:account_number) { nil }
381
+
336
382
  it { is_expected.to eq(local_details_with_swift) }
337
383
  end
338
384
  end
@@ -346,6 +392,7 @@ describe Ibandit::LocalDetailsCleaner do
346
392
 
347
393
  context "with a shorter account number" do
348
394
  let(:account_number) { "785" }
395
+
349
396
  its([:account_number]) { is_expected.to eq("00000785") }
350
397
  end
351
398
 
@@ -359,11 +406,13 @@ describe Ibandit::LocalDetailsCleaner do
359
406
 
360
407
  context "without an account number" do
361
408
  let(:account_number) { nil }
409
+
362
410
  it { is_expected.to eq(local_details_with_swift) }
363
411
  end
364
412
 
365
413
  context "without a bank code" do
366
414
  let(:bank_code) { nil }
415
+
367
416
  it { is_expected.to eq(local_details_with_swift) }
368
417
  end
369
418
  end
@@ -378,31 +427,37 @@ describe Ibandit::LocalDetailsCleaner do
378
427
 
379
428
  context "with the RIB key spaced in the account number" do
380
429
  let(:account_number) { "0500013M026 06" }
430
+
381
431
  its([:account_number]) { is_expected.to eq("0500013M02606") }
382
432
  end
383
433
 
384
434
  context "with the RIB key hyphenated in the account number" do
385
435
  let(:account_number) { "0500013M026-06" }
436
+
386
437
  its([:account_number]) { is_expected.to eq("0500013M02606") }
387
438
  end
388
439
 
389
440
  context "with the RIB key missing" do
390
441
  let(:account_number) { "0500013M026" }
442
+
391
443
  it { is_expected.to eq(local_details_with_swift) }
392
444
  end
393
445
 
394
446
  context "without a bank code" do
395
447
  let(:bank_code) { nil }
448
+
396
449
  it { is_expected.to eq(local_details_with_swift) }
397
450
  end
398
451
 
399
452
  context "without a branch code" do
400
453
  let(:branch_code) { nil }
454
+
401
455
  it { is_expected.to eq(local_details_with_swift) }
402
456
  end
403
457
 
404
458
  context "without an account number" do
405
459
  let(:account_number) { nil }
460
+
406
461
  it { is_expected.to eq(local_details_with_swift) }
407
462
  end
408
463
  end
@@ -417,52 +472,62 @@ describe Ibandit::LocalDetailsCleaner do
417
472
 
418
473
  context "with the sort code is hyphenated" do
419
474
  let(:branch_code) { "20-00-00" }
475
+
420
476
  its([:branch_code]) { is_expected.to eq("200000") }
421
477
  its([:swift_branch_code]) { is_expected.to eq("200000") }
422
478
  end
423
479
 
424
480
  context "with the sort code spaced" do
425
481
  let(:branch_code) { "20 00 00" }
482
+
426
483
  its([:branch_code]) { is_expected.to eq("200000") }
427
484
  end
428
485
 
429
486
  context "with a short account number" do
430
487
  let(:account_number) { "579135" }
488
+
431
489
  its([:account_number]) { is_expected.to eq("00579135") }
432
490
  its([:swift_account_number]) { is_expected.to eq("00579135") }
433
491
  end
434
492
 
435
493
  context "with a too-short account number" do
436
494
  let(:account_number) { "5678" }
495
+
437
496
  its([:account_number]) { is_expected.to eq(account_number) }
438
497
  end
439
498
 
440
499
  context "with the account number spaced" do
441
500
  let(:account_number) { "5577 9911" }
501
+
442
502
  its([:account_number]) { is_expected.to eq("55779911") }
443
503
  end
444
504
 
445
505
  context "with the account number hyphenated" do
446
506
  let(:account_number) { "5577-9911" }
507
+
447
508
  its([:account_number]) { is_expected.to eq("55779911") }
448
509
  end
449
510
 
450
511
  context "without a branch code" do
451
512
  let(:branch_code) { nil }
513
+
452
514
  it { is_expected.to eq(local_details_with_swift) }
453
515
  end
454
516
 
455
517
  context "without a bank code" do
456
518
  let(:bank_code) { nil }
519
+
457
520
  it { is_expected.to eq(local_details_with_swift) }
458
521
 
459
522
  context "with a BIC finder set" do
460
523
  let(:bic_finder) { double }
524
+
461
525
  before do
462
526
  allow(bic_finder).to receive(:call).with("GB", "200000").
463
527
  and_return("BARCGB22XXX")
464
528
  Ibandit.bic_finder = bic_finder
465
529
  end
530
+
466
531
  after { Ibandit.bic_finder = nil }
467
532
 
468
533
  its([:bank_code]) { is_expected.to eq("BARC") }
@@ -473,11 +538,13 @@ describe Ibandit::LocalDetailsCleaner do
473
538
  context "with a bank code and BIC finder set" do
474
539
  let(:bank_code) { "OVERRIDE" }
475
540
  let(:bic_finder) { double }
541
+
476
542
  before do
477
543
  allow(bic_finder).to receive(:call).with("GB", "200000").
478
544
  and_return("BARCGB22XXX")
479
545
  Ibandit.bic_finder = bic_finder
480
546
  end
547
+
481
548
  after { Ibandit.bic_finder = nil }
482
549
 
483
550
  its([:bank_code]) { is_expected.to eq("OVERRIDE") }
@@ -494,16 +561,19 @@ describe Ibandit::LocalDetailsCleaner do
494
561
 
495
562
  context "without an account number" do
496
563
  let(:account_number) { nil }
564
+
497
565
  it { is_expected.to eq(local_details_with_swift) }
498
566
  end
499
567
 
500
568
  context "without a bank code" do
501
569
  let(:bank_code) { nil }
570
+
502
571
  it { is_expected.to eq(local_details_with_swift) }
503
572
  end
504
573
 
505
574
  context "without a branch code" do
506
575
  let(:branch_code) { nil }
576
+
507
577
  it { is_expected.to eq(local_details_with_swift) }
508
578
  end
509
579
  end
@@ -525,12 +595,14 @@ describe Ibandit::LocalDetailsCleaner do
525
595
 
526
596
  context "with a badly formatted account number" do
527
597
  let(:account_number) { "1863000160" }
598
+
528
599
  it { is_expected.to eq(local_details_with_swift) }
529
600
  end
530
601
  end
531
602
 
532
603
  context "without an account number" do
533
604
  let(:account_number) { nil }
605
+
534
606
  it { is_expected.to eq(local_details_with_swift) }
535
607
  end
536
608
  end
@@ -565,18 +637,21 @@ describe Ibandit::LocalDetailsCleaner do
565
637
 
566
638
  context "with an invalid length account number" do
567
639
  let(:account_number) { "11773016-1111101" }
640
+
568
641
  it { is_expected.to eq(local_details_with_swift) }
569
642
  end
570
643
 
571
644
  context "with a bank code, too" do
572
645
  let(:account_number) { "11773016-11111018" }
573
646
  let(:bank_code) { "117" }
647
+
574
648
  it { is_expected.to eq(local_details_with_swift) }
575
649
  end
576
650
  end
577
651
 
578
652
  context "without an account number" do
579
653
  let(:account_number) { nil }
654
+
580
655
  it { is_expected.to eq(local_details_with_swift) }
581
656
  end
582
657
  end
@@ -591,50 +666,60 @@ describe Ibandit::LocalDetailsCleaner do
591
666
 
592
667
  context "with the sort code is hyphenated" do
593
668
  let(:branch_code) { "93-11-52" }
669
+
594
670
  its([:branch_code]) { is_expected.to eq("931152") }
595
671
  end
596
672
 
597
673
  context "with the sort code spaced" do
598
674
  let(:branch_code) { "93 11 52" }
675
+
599
676
  its([:branch_code]) { is_expected.to eq("931152") }
600
677
  end
601
678
 
602
679
  context "with a short account number" do
603
680
  let(:account_number) { "579135" }
681
+
604
682
  its([:account_number]) { is_expected.to eq("00579135") }
605
683
  end
606
684
 
607
685
  context "with a too-short account number" do
608
686
  let(:account_number) { "5678" }
687
+
609
688
  its([:account_number]) { is_expected.to eq(account_number) }
610
689
  end
611
690
 
612
691
  context "with the account number spaced" do
613
692
  let(:account_number) { "5577 9911" }
693
+
614
694
  its([:account_number]) { is_expected.to eq("55779911") }
615
695
  end
616
696
 
617
697
  context "with the account number hyphenated" do
618
698
  let(:account_number) { "5577-9911" }
699
+
619
700
  its([:account_number]) { is_expected.to eq("55779911") }
620
701
  end
621
702
 
622
703
  context "without a branch code" do
623
704
  let(:branch_code) { nil }
705
+
624
706
  it { is_expected.to eq(local_details_with_swift) }
625
707
  end
626
708
 
627
709
  context "without a bank code" do
628
710
  let(:bank_code) { nil }
711
+
629
712
  it { is_expected.to eq(local_details_with_swift) }
630
713
 
631
714
  context "with a BIC finder set" do
632
715
  let(:bic_finder) { double }
716
+
633
717
  before do
634
718
  allow(bic_finder).to receive(:call).with("IE", "931152").
635
719
  and_return("AIBKIE22XXX")
636
720
  Ibandit.bic_finder = bic_finder
637
721
  end
722
+
638
723
  after { Ibandit.bic_finder = nil }
639
724
 
640
725
  its([:bank_code]) { is_expected.to eq("AIBK") }
@@ -644,11 +729,13 @@ describe Ibandit::LocalDetailsCleaner do
644
729
  context "with a bank code and BIC finder set" do
645
730
  let(:bank_code) { "OVERRIDE" }
646
731
  let(:bic_finder) { double }
732
+
647
733
  before do
648
734
  allow(bic_finder).to receive(:call).with("IE", "931152").
649
735
  and_return("AIBKIE22XXX")
650
736
  Ibandit.bic_finder = bic_finder
651
737
  end
738
+
652
739
  after { Ibandit.bic_finder = nil }
653
740
 
654
741
  its([:bank_code]) { is_expected.to eq("OVERRIDE") }
@@ -691,12 +778,14 @@ describe Ibandit::LocalDetailsCleaner do
691
778
 
692
779
  context "without a hyphen" do
693
780
  let(:account_number) { "26-2468-606972049" }
781
+
694
782
  its([:account_number]) { is_expected.to eq("260024680606972049") }
695
783
  end
696
784
  end
697
785
 
698
786
  context "without an account number" do
699
787
  let(:account_number) { nil }
788
+
700
789
  it { is_expected.to eq(local_details_with_swift) }
701
790
  end
702
791
  end
@@ -711,26 +800,31 @@ describe Ibandit::LocalDetailsCleaner do
711
800
 
712
801
  context "with an explicit check digit" do
713
802
  before { local_details.merge!(check_digit: "Y") }
803
+
714
804
  it { is_expected.to eq(local_details_with_swift) }
715
805
  end
716
806
 
717
807
  context "with the account number not zero-padded" do
718
808
  let(:account_number) { "123456" }
809
+
719
810
  its([:account_number]) { is_expected.to eq("000000123456") }
720
811
  end
721
812
 
722
813
  context "without a bank code" do
723
814
  let(:bank_code) { nil }
815
+
724
816
  it { is_expected.to eq(local_details_with_swift) }
725
817
  end
726
818
 
727
819
  context "without a branch code" do
728
820
  let(:branch_code) { nil }
821
+
729
822
  it { is_expected.to eq(local_details_with_swift) }
730
823
  end
731
824
 
732
825
  context "without an account number" do
733
826
  let(:account_number) { nil }
827
+
734
828
  it { is_expected.to eq(local_details_with_swift) }
735
829
  end
736
830
  end
@@ -744,11 +838,13 @@ describe Ibandit::LocalDetailsCleaner do
744
838
 
745
839
  context "without an account number" do
746
840
  let(:account_number) { nil }
841
+
747
842
  it { is_expected.to eq(local_details_with_swift) }
748
843
  end
749
844
 
750
845
  context "without a bank code" do
751
846
  let(:bank_code) { nil }
847
+
752
848
  it { is_expected.to eq(local_details_with_swift) }
753
849
  end
754
850
  end
@@ -762,11 +858,13 @@ describe Ibandit::LocalDetailsCleaner do
762
858
 
763
859
  context "without an account number" do
764
860
  let(:account_number) { nil }
861
+
765
862
  it { is_expected.to eq(local_details_with_swift) }
766
863
  end
767
864
 
768
865
  context "without a bank code" do
769
866
  let(:bank_code) { nil }
867
+
770
868
  it { is_expected.to eq(local_details_with_swift) }
771
869
  end
772
870
  end
@@ -780,11 +878,13 @@ describe Ibandit::LocalDetailsCleaner do
780
878
 
781
879
  context "without an account number" do
782
880
  let(:account_number) { nil }
881
+
783
882
  it { is_expected.to eq(local_details_with_swift) }
784
883
  end
785
884
 
786
885
  context "without a bank code" do
787
886
  let(:bank_code) { nil }
887
+
788
888
  it { is_expected.to eq(local_details_with_swift) }
789
889
  end
790
890
  end
@@ -799,31 +899,37 @@ describe Ibandit::LocalDetailsCleaner do
799
899
 
800
900
  context "with the RIB key spaced in the account number" do
801
901
  let(:account_number) { "0500013M026 06" }
902
+
802
903
  its([:account_number]) { is_expected.to eq("0500013M02606") }
803
904
  end
804
905
 
805
906
  context "with the RIB key hyphenated in the account number" do
806
907
  let(:account_number) { "0500013M026-06" }
908
+
807
909
  its([:account_number]) { is_expected.to eq("0500013M02606") }
808
910
  end
809
911
 
810
912
  context "with the RIB key missing" do
811
913
  let(:account_number) { "0500013M026" }
914
+
812
915
  it { is_expected.to eq(local_details_with_swift) }
813
916
  end
814
917
 
815
918
  context "without a bank code" do
816
919
  let(:bank_code) { nil }
920
+
817
921
  it { is_expected.to eq(local_details_with_swift) }
818
922
  end
819
923
 
820
924
  context "without a branch code" do
821
925
  let(:branch_code) { nil }
926
+
822
927
  it { is_expected.to eq(local_details_with_swift) }
823
928
  end
824
929
 
825
930
  context "without an account number" do
826
931
  let(:account_number) { nil }
932
+
827
933
  it { is_expected.to eq(local_details_with_swift) }
828
934
  end
829
935
  end
@@ -838,30 +944,36 @@ describe Ibandit::LocalDetailsCleaner do
838
944
 
839
945
  context "with the account number spaced" do
840
946
  let(:account_number) { "9027 2930 51" }
947
+
841
948
  its([:account_number]) { is_expected.to eq("000000009027293051") }
842
949
  end
843
950
 
844
951
  context "with the account number hyphenated" do
845
952
  let(:account_number) { "9027-2930-51" }
953
+
846
954
  its([:account_number]) { is_expected.to eq("000000009027293051") }
847
955
  end
848
956
 
849
957
  context "without a branch code" do
850
958
  let(:branch_code) { nil }
959
+
851
960
  it { is_expected.to eq(local_details_with_swift) }
852
961
  end
853
962
 
854
963
  context "without a bank code" do
855
964
  let(:bank_code) { nil }
965
+
856
966
  it { is_expected.to eq(local_details_with_swift) }
857
967
 
858
968
  context "with a BIC finder set" do
859
969
  let(:bic_finder) { double }
970
+
860
971
  before do
861
972
  allow(bic_finder).to receive(:call).with("MT", "44093").
862
973
  and_return("MMEBMTMTXXX")
863
974
  Ibandit.bic_finder = bic_finder
864
975
  end
976
+
865
977
  after { Ibandit.bic_finder = nil }
866
978
 
867
979
  its([:bank_code]) { is_expected.to eq("MMEB") }
@@ -871,11 +983,13 @@ describe Ibandit::LocalDetailsCleaner do
871
983
  context "with a bank code and BIC finder set" do
872
984
  let(:bank_code) { "OVERRIDE" }
873
985
  let(:bic_finder) { double }
986
+
874
987
  before do
875
988
  allow(bic_finder).to receive(:call).with("MT", "44093").
876
989
  and_return("MMEBMTMTXXX")
877
990
  Ibandit.bic_finder = bic_finder
878
991
  end
992
+
879
993
  after { Ibandit.bic_finder = nil }
880
994
 
881
995
  its([:bank_code]) { is_expected.to eq("OVERRIDE") }
@@ -891,21 +1005,25 @@ describe Ibandit::LocalDetailsCleaner do
891
1005
 
892
1006
  context "without a bank code" do
893
1007
  let(:bank_code) { nil }
1008
+
894
1009
  it { is_expected.to eq(local_details_with_swift) }
895
1010
  end
896
1011
 
897
1012
  context "without a branch code" do
898
1013
  let(:branch_code) { nil }
1014
+
899
1015
  it { is_expected.to eq(local_details_with_swift) }
900
1016
  end
901
1017
 
902
1018
  context "without an account number" do
903
1019
  let(:account_number) { nil }
1020
+
904
1021
  it { is_expected.to eq(local_details_with_swift) }
905
1022
  end
906
1023
 
907
1024
  context "with an account number that needs zero-padding" do
908
1025
  let(:account_number) { "417164300" }
1026
+
909
1027
  its([:account_number]) { is_expected.to eq("0417164300") }
910
1028
  end
911
1029
  end
@@ -928,6 +1046,7 @@ describe Ibandit::LocalDetailsCleaner do
928
1046
 
929
1047
  context "without an account number" do
930
1048
  let(:account_number) { nil }
1049
+
931
1050
  it { is_expected.to eq(local_details_with_swift) }
932
1051
  end
933
1052
  end
@@ -959,12 +1078,14 @@ describe Ibandit::LocalDetailsCleaner do
959
1078
 
960
1079
  context "when the account number is shorter than 6 chars" do
961
1080
  let(:account_number) { "12345" }
1081
+
962
1082
  its([:account_number]) { is_expected.to be_nil }
963
1083
  end
964
1084
  end
965
1085
 
966
1086
  context "without an account number" do
967
1087
  let(:account_number) { nil }
1088
+
968
1089
  it { is_expected.to eq(local_details_with_swift) }
969
1090
  end
970
1091
  end
@@ -987,6 +1108,7 @@ describe Ibandit::LocalDetailsCleaner do
987
1108
 
988
1109
  context "without an account number" do
989
1110
  let(:account_number) { nil }
1111
+
990
1112
  it { is_expected.to eq(local_details_with_swift) }
991
1113
  end
992
1114
  end
@@ -1001,16 +1123,19 @@ describe Ibandit::LocalDetailsCleaner do
1001
1123
 
1002
1124
  context "without a bank code" do
1003
1125
  let(:bank_code) { nil }
1126
+
1004
1127
  it { is_expected.to eq(local_details_with_swift) }
1005
1128
  end
1006
1129
 
1007
1130
  context "without a branch code" do
1008
1131
  let(:branch_code) { nil }
1132
+
1009
1133
  it { is_expected.to eq(local_details_with_swift) }
1010
1134
  end
1011
1135
 
1012
1136
  context "without an account number" do
1013
1137
  let(:account_number) { nil }
1138
+
1014
1139
  it { is_expected.to eq(local_details_with_swift) }
1015
1140
  end
1016
1141
  end
@@ -1024,11 +1149,13 @@ describe Ibandit::LocalDetailsCleaner do
1024
1149
 
1025
1150
  context "without an account number" do
1026
1151
  let(:account_number) { nil }
1152
+
1027
1153
  it { is_expected.to eq(local_details_with_swift) }
1028
1154
  end
1029
1155
 
1030
1156
  context "without a bank code" do
1031
1157
  let(:bank_code) { nil }
1158
+
1032
1159
  it { is_expected.to eq(local_details_with_swift) }
1033
1160
  end
1034
1161
  end
@@ -1045,6 +1172,7 @@ describe Ibandit::LocalDetailsCleaner do
1045
1172
 
1046
1173
  context "without an account number" do
1047
1174
  let(:account_number) { nil }
1175
+
1048
1176
  it { is_expected.to eq(local_details_with_swift) }
1049
1177
  end
1050
1178
 
@@ -1068,16 +1196,19 @@ describe Ibandit::LocalDetailsCleaner do
1068
1196
 
1069
1197
  context "with an account number which needs zero-padding" do
1070
1198
  let(:account_number) { "123438" }
1199
+
1071
1200
  its([:account_number]) { is_expected.to eq("0000123438") }
1072
1201
  end
1073
1202
 
1074
1203
  context "without a bank code" do
1075
1204
  let(:bank_code) { nil }
1205
+
1076
1206
  it { is_expected.to eq(local_details_with_swift) }
1077
1207
  end
1078
1208
 
1079
1209
  context "without an account number" do
1080
1210
  let(:account_number) { nil }
1211
+
1081
1212
  it { is_expected.to eq(local_details_with_swift) }
1082
1213
  end
1083
1214
  end
@@ -1092,23 +1223,27 @@ describe Ibandit::LocalDetailsCleaner do
1092
1223
  context "with an account number prefix" do
1093
1224
  let(:prefix) { "000019" }
1094
1225
  let(:account_number) { "8742637541" }
1226
+
1095
1227
  before { local_details.merge!(account_number_prefix: prefix) }
1096
1228
 
1097
1229
  its([:account_number]) { is_expected.to eq("0000198742637541") }
1098
1230
 
1099
1231
  context "which needs zero-padding" do
1100
1232
  let(:prefix) { "19" }
1233
+
1101
1234
  its([:account_number]) { is_expected.to eq("0000198742637541") }
1102
1235
  end
1103
1236
  end
1104
1237
 
1105
1238
  context "without a bank code" do
1106
1239
  let(:bank_code) { nil }
1240
+
1107
1241
  it { is_expected.to eq(local_details_with_swift) }
1108
1242
  end
1109
1243
 
1110
1244
  context "without an account number" do
1111
1245
  let(:account_number) { nil }
1246
+
1112
1247
  it { is_expected.to eq(local_details_with_swift) }
1113
1248
  end
1114
1249
  end
@@ -1123,26 +1258,31 @@ describe Ibandit::LocalDetailsCleaner do
1123
1258
 
1124
1259
  context "with an explicit check digit" do
1125
1260
  before { local_details.merge!(check_digit: "Y") }
1261
+
1126
1262
  it { is_expected.to eq(local_details_with_swift) }
1127
1263
  end
1128
1264
 
1129
1265
  context "with the account number not zero-padded" do
1130
1266
  let(:account_number) { "123456" }
1267
+
1131
1268
  its([:account_number]) { is_expected.to eq("000000123456") }
1132
1269
  end
1133
1270
 
1134
1271
  context "without a bank code" do
1135
1272
  let(:bank_code) { nil }
1273
+
1136
1274
  it { is_expected.to eq(local_details_with_swift) }
1137
1275
  end
1138
1276
 
1139
1277
  context "without a branch code" do
1140
1278
  let(:branch_code) { nil }
1279
+
1141
1280
  it { is_expected.to eq(local_details_with_swift) }
1142
1281
  end
1143
1282
 
1144
1283
  context "without an account number" do
1145
1284
  let(:account_number) { nil }
1285
+
1146
1286
  it { is_expected.to eq(local_details_with_swift) }
1147
1287
  end
1148
1288
  end