ibandit 0.11.28 → 1.0.0

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