ibandit 0.11.6 → 0.11.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +7 -6
- data/.rubocop_todo.yml +4 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile +8 -0
- data/README.md +90 -30
- data/data/structures.yml +9 -0
- data/ibandit.gemspec +23 -19
- data/lib/ibandit.rb +18 -18
- data/lib/ibandit/check_digit.rb +8 -8
- data/lib/ibandit/constants.rb +14 -5
- data/lib/ibandit/german_details_converter.rb +598 -598
- data/lib/ibandit/iban.rb +90 -37
- data/lib/ibandit/iban_assembler.rb +15 -13
- data/lib/ibandit/iban_splitter.rb +4 -4
- data/lib/ibandit/local_details_cleaner.rb +94 -85
- data/lib/ibandit/pseudo_iban_assembler.rb +2 -2
- data/lib/ibandit/pseudo_iban_splitter.rb +15 -25
- data/lib/ibandit/sweden/bank_lookup.rb +1 -1
- data/lib/ibandit/sweden/local_details_converter.rb +7 -7
- data/lib/ibandit/sweden/validator.rb +5 -5
- data/lib/ibandit/version.rb +1 -1
- data/spec/ibandit/german_details_converter_spec.rb +23 -22
- data/spec/ibandit/iban_assembler_spec.rb +310 -310
- data/spec/ibandit/iban_spec.rb +1087 -712
- data/spec/ibandit/iban_splitter_spec.rb +14 -14
- data/spec/ibandit/local_details_cleaner_spec.rb +473 -452
- data/spec/ibandit/pseudo_iban_assembler_spec.rb +54 -18
- data/spec/ibandit/pseudo_iban_splitter_spec.rb +13 -22
- data/spec/ibandit/structure_spec.rb +3 -3
- data/spec/ibandit/sweden/local_details_converter_spec.rb +125 -125
- data/spec/ibandit/sweden/validator_spec.rb +88 -88
- data/spec/spec_helper.rb +10 -10
- metadata +48 -20
@@ -1,18 +1,18 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe Ibandit::IBANSplitter do
|
4
4
|
subject(:split) { described_class.split(iban_code) }
|
5
5
|
|
6
|
-
context
|
7
|
-
let(:iban_code) {
|
8
|
-
its([:country_code]) { is_expected.to eq(
|
9
|
-
its([:check_digits]) { is_expected.to eq(
|
10
|
-
its([:bank_code]) { is_expected.to eq(
|
11
|
-
its([:branch_code]) { is_expected.to eq(
|
12
|
-
its([:account_number]) { is_expected.to eq(
|
6
|
+
context "with a valid IBAN" do
|
7
|
+
let(:iban_code) { "GB82WEST12345698765432" }
|
8
|
+
its([:country_code]) { is_expected.to eq("GB") }
|
9
|
+
its([:check_digits]) { is_expected.to eq("82") }
|
10
|
+
its([:bank_code]) { is_expected.to eq("WEST") }
|
11
|
+
its([:branch_code]) { is_expected.to eq("123456") }
|
12
|
+
its([:account_number]) { is_expected.to eq("98765432") }
|
13
13
|
end
|
14
14
|
|
15
|
-
context
|
15
|
+
context "with nil" do
|
16
16
|
let(:iban_code) { nil }
|
17
17
|
its([:country_code]) { is_expected.to eq(nil) }
|
18
18
|
its([:check_digits]) { is_expected.to eq(nil) }
|
@@ -21,8 +21,8 @@ describe Ibandit::IBANSplitter do
|
|
21
21
|
its([:account_number]) { is_expected.to eq(nil) }
|
22
22
|
end
|
23
23
|
|
24
|
-
context
|
25
|
-
let(:iban_code) {
|
24
|
+
context "with an empty string" do
|
25
|
+
let(:iban_code) { "" }
|
26
26
|
its([:country_code]) { is_expected.to eq(nil) }
|
27
27
|
its([:check_digits]) { is_expected.to eq(nil) }
|
28
28
|
its([:bank_code]) { is_expected.to eq(nil) }
|
@@ -30,9 +30,9 @@ describe Ibandit::IBANSplitter do
|
|
30
30
|
its([:account_number]) { is_expected.to eq(nil) }
|
31
31
|
end
|
32
32
|
|
33
|
-
context
|
34
|
-
let(:iban_code) {
|
35
|
-
its([:country_code]) { is_expected.to eq(
|
33
|
+
context "with an invalid length IBAN" do
|
34
|
+
let(:iban_code) { "MC9320052222100112233M445" }
|
35
|
+
its([:country_code]) { is_expected.to eq("MC") }
|
36
36
|
its([:check_digits]) { is_expected.to eq(nil) }
|
37
37
|
its([:bank_code]) { is_expected.to eq(nil) }
|
38
38
|
its([:branch_code]) { is_expected.to eq(nil) }
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe Ibandit::LocalDetailsCleaner do
|
4
4
|
subject(:cleaned) { described_class.clean(local_details) }
|
@@ -7,7 +7,7 @@ describe Ibandit::LocalDetailsCleaner do
|
|
7
7
|
country_code: country_code,
|
8
8
|
bank_code: bank_code,
|
9
9
|
branch_code: branch_code,
|
10
|
-
account_number: account_number
|
10
|
+
account_number: account_number,
|
11
11
|
}
|
12
12
|
end
|
13
13
|
|
@@ -15,7 +15,7 @@ describe Ibandit::LocalDetailsCleaner do
|
|
15
15
|
local_details.merge(
|
16
16
|
swift_bank_code: bank_code,
|
17
17
|
swift_branch_code: branch_code,
|
18
|
-
swift_account_number: account_number
|
18
|
+
swift_account_number: account_number,
|
19
19
|
)
|
20
20
|
end
|
21
21
|
|
@@ -24,1066 +24,1087 @@ describe Ibandit::LocalDetailsCleaner do
|
|
24
24
|
let(:branch_code) { nil }
|
25
25
|
let(:account_number) { nil }
|
26
26
|
|
27
|
-
context
|
27
|
+
context "without country code" do
|
28
28
|
it { is_expected.to eq(local_details_with_swift) }
|
29
29
|
end
|
30
30
|
|
31
|
-
context
|
32
|
-
let(:country_code) {
|
31
|
+
context "with an unsupported country code" do
|
32
|
+
let(:country_code) { "FU" }
|
33
33
|
it { is_expected.to eq(local_details_with_swift) }
|
34
34
|
end
|
35
35
|
|
36
|
-
context
|
37
|
-
let(:country_code) {
|
38
|
-
let(:bank_code) {
|
39
|
-
let(:account_number) {
|
36
|
+
context "Austria" do
|
37
|
+
let(:country_code) { "AT" }
|
38
|
+
let(:bank_code) { "19043" }
|
39
|
+
let(:account_number) { "00234573201" }
|
40
40
|
|
41
41
|
it { is_expected.to eq(local_details_with_swift) }
|
42
42
|
|
43
|
-
context
|
44
|
-
let(:account_number) {
|
45
|
-
its([:account_number]) { is_expected.to eq(
|
43
|
+
context "with an account number which needs zero-padding" do
|
44
|
+
let(:account_number) { "234573201" }
|
45
|
+
its([:account_number]) { is_expected.to eq("00234573201") }
|
46
46
|
end
|
47
47
|
|
48
|
-
context
|
49
|
-
let(:account_number) {
|
50
|
-
its([:account_number]) { is_expected.to eq(
|
48
|
+
context "with an account number under 4 digits" do
|
49
|
+
let(:account_number) { "123" }
|
50
|
+
its([:account_number]) { is_expected.to eq("123") }
|
51
51
|
end
|
52
52
|
|
53
|
-
context
|
54
|
-
let(:account_number) {
|
53
|
+
context "with a long account number" do
|
54
|
+
let(:account_number) { "234573201999" }
|
55
55
|
it { is_expected.to eq(local_details_with_swift) }
|
56
56
|
end
|
57
57
|
|
58
|
-
context
|
58
|
+
context "without an account number" do
|
59
59
|
let(:account_number) { nil }
|
60
60
|
it { is_expected.to eq(local_details_with_swift) }
|
61
61
|
end
|
62
62
|
|
63
|
-
context
|
64
|
-
let(:bank_code) {
|
63
|
+
context "with a short bank code" do
|
64
|
+
let(:bank_code) { "1904" }
|
65
65
|
it { is_expected.to eq(local_details_with_swift) }
|
66
66
|
end
|
67
67
|
|
68
|
-
context
|
69
|
-
let(:bank_code) {
|
68
|
+
context "with a long bank code" do
|
69
|
+
let(:bank_code) { "190430" }
|
70
70
|
it { is_expected.to eq(local_details_with_swift) }
|
71
71
|
end
|
72
72
|
|
73
|
-
context
|
73
|
+
context "without a bank code" do
|
74
74
|
let(:bank_code) { nil }
|
75
75
|
it { is_expected.to eq(local_details_with_swift) }
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
|
-
context
|
80
|
-
let(:country_code) {
|
81
|
-
let(:account_number) {
|
79
|
+
context "Australia" do
|
80
|
+
let(:country_code) { "AU" }
|
81
|
+
let(:account_number) { "123456789" }
|
82
|
+
|
83
|
+
context "with dashes" do
|
84
|
+
let(:branch_code) { "123-456" }
|
85
|
+
|
86
|
+
its([:country_code]) { is_expected.to eq(country_code) }
|
87
|
+
its([:account_number]) { is_expected.to eq(account_number) }
|
88
|
+
its([:branch_code]) { is_expected.to eq("123456") }
|
89
|
+
end
|
90
|
+
|
91
|
+
context "without dashes" do
|
92
|
+
let(:branch_code) { "123456" }
|
93
|
+
|
94
|
+
its([:country_code]) { is_expected.to eq(country_code) }
|
95
|
+
its([:account_number]) { is_expected.to eq(account_number) }
|
96
|
+
its([:branch_code]) { is_expected.to eq("123456") }
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
context "Belgium" do
|
101
|
+
let(:country_code) { "BE" }
|
102
|
+
let(:account_number) { "510007547061" }
|
82
103
|
|
83
104
|
its([:country_code]) { is_expected.to eq(country_code) }
|
84
105
|
its([:account_number]) { is_expected.to eq(account_number) }
|
85
|
-
its([:bank_code]) { is_expected.to eq(
|
106
|
+
its([:bank_code]) { is_expected.to eq("510") }
|
86
107
|
|
87
|
-
context
|
88
|
-
let(:account_number) {
|
89
|
-
its([:bank_code]) { is_expected.to eq(
|
90
|
-
its([:account_number]) { is_expected.to eq(
|
108
|
+
context "with dashes" do
|
109
|
+
let(:account_number) { "510-0075470-61" }
|
110
|
+
its([:bank_code]) { is_expected.to eq("510") }
|
111
|
+
its([:account_number]) { is_expected.to eq("510007547061") }
|
91
112
|
end
|
92
113
|
|
93
|
-
context
|
114
|
+
context "without an account number" do
|
94
115
|
let(:account_number) { nil }
|
95
116
|
it { is_expected.to eq(local_details_with_swift) }
|
96
117
|
end
|
97
118
|
end
|
98
119
|
|
99
|
-
context
|
100
|
-
let(:country_code) {
|
101
|
-
let(:bank_code) {
|
102
|
-
let(:branch_code) {
|
103
|
-
let(:account_number) {
|
120
|
+
context "Bulgaria" do
|
121
|
+
let(:country_code) { "BG" }
|
122
|
+
let(:bank_code) { "BNBG" }
|
123
|
+
let(:branch_code) { "9661" }
|
124
|
+
let(:account_number) { "1020345678" }
|
104
125
|
|
105
126
|
it { is_expected.to eq(local_details_with_swift) }
|
106
127
|
|
107
|
-
context
|
128
|
+
context "without an account number" do
|
108
129
|
let(:account_number) { nil }
|
109
130
|
it { is_expected.to eq(local_details_with_swift) }
|
110
131
|
end
|
111
132
|
|
112
|
-
context
|
133
|
+
context "without a branch code" do
|
113
134
|
let(:branch_code) { nil }
|
114
135
|
it { is_expected.to eq(local_details_with_swift) }
|
115
136
|
end
|
116
137
|
|
117
|
-
context
|
138
|
+
context "without a bank code" do
|
118
139
|
let(:bank_code) { nil }
|
119
140
|
it { is_expected.to eq(local_details_with_swift) }
|
120
141
|
end
|
121
142
|
end
|
122
143
|
|
123
|
-
context
|
124
|
-
let(:country_code) {
|
125
|
-
let(:account_number) {
|
126
|
-
let(:bank_code) {
|
127
|
-
let(:branch_code) {
|
144
|
+
context "Cyprus" do
|
145
|
+
let(:country_code) { "CY" }
|
146
|
+
let(:account_number) { "0000001200527600" }
|
147
|
+
let(:bank_code) { "002" }
|
148
|
+
let(:branch_code) { "00128" }
|
128
149
|
|
129
150
|
it { is_expected.to eq(local_details_with_swift) }
|
130
151
|
|
131
|
-
context
|
132
|
-
let(:account_number) {
|
133
|
-
its([:account_number]) { is_expected.to eq(
|
152
|
+
context "with a short account number" do
|
153
|
+
let(:account_number) { "1200527600" }
|
154
|
+
its([:account_number]) { is_expected.to eq("0000001200527600") }
|
134
155
|
end
|
135
156
|
|
136
|
-
context
|
137
|
-
let(:account_number) {
|
157
|
+
context "with a too-short account number" do
|
158
|
+
let(:account_number) { "123456" }
|
138
159
|
its([:account_number]) { is_expected.to eq(account_number) }
|
139
160
|
end
|
140
161
|
|
141
|
-
context
|
142
|
-
let(:account_number) {
|
162
|
+
context "with a long account number" do
|
163
|
+
let(:account_number) { "00000001200527600" }
|
143
164
|
it { is_expected.to eq(local_details_with_swift) }
|
144
165
|
end
|
145
166
|
|
146
|
-
context
|
167
|
+
context "without an account number" do
|
147
168
|
let(:account_number) { nil }
|
148
169
|
it { is_expected.to eq(local_details_with_swift) }
|
149
170
|
end
|
150
171
|
|
151
|
-
context
|
152
|
-
let(:bank_code) {
|
172
|
+
context "with the branch code in the bank code field" do
|
173
|
+
let(:bank_code) { "002 00128" }
|
153
174
|
let(:branch_code) { nil }
|
154
|
-
its([:bank_code]) { is_expected.to eq(
|
155
|
-
its([:branch_code]) { is_expected.to eq(
|
175
|
+
its([:bank_code]) { is_expected.to eq("002") }
|
176
|
+
its([:branch_code]) { is_expected.to eq("00128") }
|
156
177
|
end
|
157
178
|
|
158
|
-
context
|
179
|
+
context "without a bank code" do
|
159
180
|
let(:bank_code) { nil }
|
160
181
|
it { is_expected.to eq(local_details_with_swift) }
|
161
182
|
end
|
162
183
|
end
|
163
184
|
|
164
|
-
context
|
165
|
-
let(:country_code) {
|
166
|
-
let(:bank_code) {
|
167
|
-
let(:account_number) {
|
185
|
+
context "Czech Republic" do
|
186
|
+
let(:country_code) { "CZ" }
|
187
|
+
let(:bank_code) { "0800" }
|
188
|
+
let(:account_number) { "0000192000145399" }
|
168
189
|
|
169
190
|
it { is_expected.to eq(local_details_with_swift) }
|
170
191
|
|
171
|
-
context
|
172
|
-
let(:prefix) {
|
173
|
-
let(:account_number) {
|
192
|
+
context "with an account number prefix" do
|
193
|
+
let(:prefix) { "000019" }
|
194
|
+
let(:account_number) { "2000145399" }
|
174
195
|
before { local_details.merge!(account_number_prefix: prefix) }
|
175
196
|
|
176
|
-
its([:account_number]) { is_expected.to eq(
|
197
|
+
its([:account_number]) { is_expected.to eq("0000192000145399") }
|
177
198
|
|
178
|
-
context
|
179
|
-
let(:prefix) {
|
180
|
-
its([:account_number]) { is_expected.to eq(
|
199
|
+
context "which needs zero-padding" do
|
200
|
+
let(:prefix) { "19" }
|
201
|
+
its([:account_number]) { is_expected.to eq("0000192000145399") }
|
181
202
|
end
|
182
203
|
end
|
183
204
|
|
184
|
-
context
|
205
|
+
context "without a bank code" do
|
185
206
|
let(:bank_code) { nil }
|
186
207
|
it { is_expected.to eq(local_details_with_swift) }
|
187
208
|
end
|
188
209
|
|
189
|
-
context
|
210
|
+
context "without an account number" do
|
190
211
|
let(:account_number) { nil }
|
191
212
|
it { is_expected.to eq(local_details_with_swift) }
|
192
213
|
end
|
193
214
|
end
|
194
215
|
|
195
|
-
context
|
196
|
-
let(:country_code) {
|
197
|
-
let(:bank_code) {
|
198
|
-
let(:account_number) {
|
216
|
+
context "Germany" do
|
217
|
+
let(:country_code) { "DE" }
|
218
|
+
let(:bank_code) { "37040044" }
|
219
|
+
let(:account_number) { "0532013000" }
|
199
220
|
|
200
221
|
it { is_expected.to eq(local_details_with_swift) }
|
201
222
|
|
202
|
-
context
|
223
|
+
context "without a bank code" do
|
203
224
|
let(:bank_code) { nil }
|
204
225
|
it { is_expected.to eq(local_details_with_swift) }
|
205
226
|
end
|
206
227
|
|
207
|
-
context
|
228
|
+
context "without an account number" do
|
208
229
|
let(:account_number) { nil }
|
209
230
|
it { is_expected.to eq(local_details_with_swift) }
|
210
231
|
end
|
211
232
|
|
212
|
-
context
|
213
|
-
let(:account_number) {
|
233
|
+
context "with an excessively short account number" do
|
234
|
+
let(:account_number) { "666" }
|
214
235
|
its([:account_number]) { is_expected.to eq(account_number) }
|
215
236
|
end
|
216
237
|
|
217
|
-
context
|
218
|
-
let(:bank_code) {
|
219
|
-
let(:account_number) {
|
238
|
+
context "with a pseudo account number" do
|
239
|
+
let(:bank_code) { "37080040" }
|
240
|
+
let(:account_number) { "111" }
|
220
241
|
its([:bank_code]) { is_expected.to eq(bank_code) }
|
221
|
-
its([:account_number]) { is_expected.to eq(
|
242
|
+
its([:account_number]) { is_expected.to eq("0215022000") }
|
222
243
|
end
|
223
244
|
|
224
|
-
context
|
225
|
-
let(:account_number) {
|
226
|
-
let(:bank_code) {
|
245
|
+
context "with unsupported account details" do
|
246
|
+
let(:account_number) { "7955791111" }
|
247
|
+
let(:bank_code) { "20000000" }
|
227
248
|
it { is_expected.to eq(local_details_with_swift) }
|
228
249
|
end
|
229
250
|
end
|
230
251
|
|
231
|
-
context
|
232
|
-
let(:country_code) {
|
233
|
-
let(:bank_code) {
|
234
|
-
let(:account_number) {
|
252
|
+
context "Denmark" do
|
253
|
+
let(:country_code) { "DK" }
|
254
|
+
let(:bank_code) { "40" }
|
255
|
+
let(:account_number) { "440116243" }
|
235
256
|
|
236
|
-
its([:bank_code]) { is_expected.to eq(
|
237
|
-
its([:account_number]) { is_expected.to eq(
|
257
|
+
its([:bank_code]) { is_expected.to eq("0040") }
|
258
|
+
its([:account_number]) { is_expected.to eq("0440116243") }
|
238
259
|
|
239
|
-
context
|
260
|
+
context "with bank and branch codes in the account number" do
|
240
261
|
let(:bank_code) { nil }
|
241
262
|
let(:branch_code) { nil }
|
242
|
-
let(:account_number) {
|
263
|
+
let(:account_number) { "345-317-9681" }
|
243
264
|
|
244
|
-
its([:bank_code]) { is_expected.to eq(
|
245
|
-
its([:account_number]) { is_expected.to eq(
|
265
|
+
its([:bank_code]) { is_expected.to eq("0345") }
|
266
|
+
its([:account_number]) { is_expected.to eq("0003179681") }
|
246
267
|
end
|
247
268
|
|
248
|
-
context
|
269
|
+
context "with a space-separated 14-digit account number" do
|
249
270
|
let(:bank_code) { nil }
|
250
271
|
let(:branch_code) { nil }
|
251
|
-
let(:account_number) {
|
272
|
+
let(:account_number) { "0345 0003179681" }
|
252
273
|
|
253
|
-
its([:bank_code]) { is_expected.to eq(
|
254
|
-
its([:account_number]) { is_expected.to eq(
|
274
|
+
its([:bank_code]) { is_expected.to eq("0345") }
|
275
|
+
its([:account_number]) { is_expected.to eq("0003179681") }
|
255
276
|
end
|
256
277
|
|
257
|
-
context
|
278
|
+
context "with a space-separated 13-digit account number" do
|
258
279
|
let(:bank_code) { nil }
|
259
280
|
let(:branch_code) { nil }
|
260
|
-
let(:account_number) {
|
281
|
+
let(:account_number) { "0345 003179681" }
|
261
282
|
|
262
283
|
it { is_expected.to eq(local_details_with_swift) }
|
263
284
|
end
|
264
285
|
|
265
|
-
context
|
286
|
+
context "without an account number" do
|
266
287
|
let(:account_number) { nil }
|
267
288
|
it { is_expected.to eq(local_details_with_swift) }
|
268
289
|
end
|
269
290
|
end
|
270
291
|
|
271
|
-
context
|
272
|
-
let(:country_code) {
|
273
|
-
let(:account_number) {
|
292
|
+
context "Estonia" do
|
293
|
+
let(:country_code) { "EE" }
|
294
|
+
let(:account_number) { "0221020145685" }
|
274
295
|
|
275
|
-
its([:bank_code]) { is_expected.to eq(
|
276
|
-
its([:account_number]) { is_expected.to eq(
|
296
|
+
its([:bank_code]) { is_expected.to eq("22") }
|
297
|
+
its([:account_number]) { is_expected.to eq("00221020145685") }
|
277
298
|
|
278
|
-
context
|
279
|
-
let(:account_number) {
|
280
|
-
its([:bank_code]) { is_expected.to eq(
|
281
|
-
its([:account_number]) { is_expected.to eq(
|
299
|
+
context "with an account number that needs translating" do
|
300
|
+
let(:account_number) { "111020145685" }
|
301
|
+
its([:bank_code]) { is_expected.to eq("22") }
|
302
|
+
its([:account_number]) { is_expected.to eq("00111020145685") }
|
282
303
|
end
|
283
304
|
|
284
|
-
context
|
305
|
+
context "without an account number" do
|
285
306
|
let(:account_number) { nil }
|
286
307
|
it { is_expected.to eq(local_details_with_swift) }
|
287
308
|
end
|
288
309
|
end
|
289
310
|
|
290
|
-
context
|
291
|
-
let(:country_code) {
|
292
|
-
let(:bank_code) {
|
293
|
-
let(:branch_code) {
|
294
|
-
let(:account_number) {
|
311
|
+
context "Spain" do
|
312
|
+
let(:country_code) { "ES" }
|
313
|
+
let(:bank_code) { "2310" }
|
314
|
+
let(:branch_code) { "0001" }
|
315
|
+
let(:account_number) { "180000012345" }
|
295
316
|
|
296
317
|
it { is_expected.to eq(local_details_with_swift) }
|
297
318
|
|
298
|
-
context
|
319
|
+
context "with bank and branch codes in the account number" do
|
299
320
|
let(:bank_code) { nil }
|
300
321
|
let(:branch_code) { nil }
|
301
|
-
let(:account_number) {
|
322
|
+
let(:account_number) { "2310-0001-18-0000012345" }
|
302
323
|
|
303
|
-
its([:bank_code]) { is_expected.to eq(
|
304
|
-
its([:branch_code]) { is_expected.to eq(
|
305
|
-
its([:account_number]) { is_expected.to eq(
|
324
|
+
its([:bank_code]) { is_expected.to eq("2310") }
|
325
|
+
its([:branch_code]) { is_expected.to eq("0001") }
|
326
|
+
its([:account_number]) { is_expected.to eq("180000012345") }
|
306
327
|
end
|
307
328
|
|
308
|
-
context
|
309
|
-
let(:account_number) {
|
310
|
-
its([:account_number]) { is_expected.to eq(
|
329
|
+
context "with spaces in the account number" do
|
330
|
+
let(:account_number) { "18 0000012345" }
|
331
|
+
its([:account_number]) { is_expected.to eq("180000012345") }
|
311
332
|
end
|
312
333
|
|
313
|
-
context
|
334
|
+
context "without an account number" do
|
314
335
|
let(:account_number) { nil }
|
315
336
|
it { is_expected.to eq(local_details_with_swift) }
|
316
337
|
end
|
317
338
|
end
|
318
339
|
|
319
|
-
context
|
320
|
-
let(:country_code) {
|
321
|
-
let(:bank_code) {
|
322
|
-
let(:account_number) {
|
340
|
+
context "Finland" do
|
341
|
+
let(:country_code) { "FI" }
|
342
|
+
let(:bank_code) { "123456" }
|
343
|
+
let(:account_number) { "00000785" }
|
323
344
|
|
324
345
|
it { is_expected.to eq(local_details_with_swift) }
|
325
346
|
|
326
|
-
context
|
327
|
-
let(:account_number) {
|
328
|
-
its([:account_number]) { is_expected.to eq(
|
347
|
+
context "with a shorter account number" do
|
348
|
+
let(:account_number) { "785" }
|
349
|
+
its([:account_number]) { is_expected.to eq("00000785") }
|
329
350
|
end
|
330
351
|
|
331
|
-
context
|
332
|
-
let(:account_number) {
|
333
|
-
let(:bank_code) {
|
352
|
+
context "with a savings bank account_number in traditional format" do
|
353
|
+
let(:account_number) { "78510" }
|
354
|
+
let(:bank_code) { "423456" }
|
334
355
|
|
335
356
|
its([:bank_code]) { is_expected.to eq(bank_code) }
|
336
|
-
its([:account_number]) { is_expected.to eq(
|
357
|
+
its([:account_number]) { is_expected.to eq("70008510") }
|
337
358
|
end
|
338
359
|
|
339
|
-
context
|
360
|
+
context "without an account number" do
|
340
361
|
let(:account_number) { nil }
|
341
362
|
it { is_expected.to eq(local_details_with_swift) }
|
342
363
|
end
|
343
364
|
|
344
|
-
context
|
365
|
+
context "without a bank code" do
|
345
366
|
let(:bank_code) { nil }
|
346
367
|
it { is_expected.to eq(local_details_with_swift) }
|
347
368
|
end
|
348
369
|
end
|
349
370
|
|
350
|
-
context
|
351
|
-
let(:country_code) {
|
352
|
-
let(:bank_code) {
|
353
|
-
let(:branch_code) {
|
354
|
-
let(:account_number) {
|
371
|
+
context "France" do
|
372
|
+
let(:country_code) { "FR" }
|
373
|
+
let(:bank_code) { "20041" }
|
374
|
+
let(:branch_code) { "01005" }
|
375
|
+
let(:account_number) { "0500013M02606" }
|
355
376
|
|
356
377
|
it { is_expected.to eq(local_details_with_swift) }
|
357
378
|
|
358
|
-
context
|
359
|
-
let(:account_number) {
|
360
|
-
its([:account_number]) { is_expected.to eq(
|
379
|
+
context "with the RIB key spaced in the account number" do
|
380
|
+
let(:account_number) { "0500013M026 06" }
|
381
|
+
its([:account_number]) { is_expected.to eq("0500013M02606") }
|
361
382
|
end
|
362
383
|
|
363
|
-
context
|
364
|
-
let(:account_number) {
|
365
|
-
its([:account_number]) { is_expected.to eq(
|
384
|
+
context "with the RIB key hyphenated in the account number" do
|
385
|
+
let(:account_number) { "0500013M026-06" }
|
386
|
+
its([:account_number]) { is_expected.to eq("0500013M02606") }
|
366
387
|
end
|
367
388
|
|
368
|
-
context
|
369
|
-
let(:account_number) {
|
389
|
+
context "with the RIB key missing" do
|
390
|
+
let(:account_number) { "0500013M026" }
|
370
391
|
it { is_expected.to eq(local_details_with_swift) }
|
371
392
|
end
|
372
393
|
|
373
|
-
context
|
394
|
+
context "without a bank code" do
|
374
395
|
let(:bank_code) { nil }
|
375
396
|
it { is_expected.to eq(local_details_with_swift) }
|
376
397
|
end
|
377
398
|
|
378
|
-
context
|
399
|
+
context "without a branch code" do
|
379
400
|
let(:branch_code) { nil }
|
380
401
|
it { is_expected.to eq(local_details_with_swift) }
|
381
402
|
end
|
382
403
|
|
383
|
-
context
|
404
|
+
context "without an account number" do
|
384
405
|
let(:account_number) { nil }
|
385
406
|
it { is_expected.to eq(local_details_with_swift) }
|
386
407
|
end
|
387
408
|
end
|
388
409
|
|
389
|
-
context
|
390
|
-
let(:country_code) {
|
391
|
-
let(:bank_code) {
|
392
|
-
let(:branch_code) {
|
393
|
-
let(:account_number) {
|
410
|
+
context "United Kingdom" do
|
411
|
+
let(:country_code) { "GB" }
|
412
|
+
let(:bank_code) { "BARC" }
|
413
|
+
let(:branch_code) { "200000" }
|
414
|
+
let(:account_number) { "55779911" }
|
394
415
|
|
395
416
|
it { is_expected.to eq(local_details_with_swift) }
|
396
417
|
|
397
|
-
context
|
398
|
-
let(:branch_code) {
|
399
|
-
its([:branch_code]) { is_expected.to eq(
|
400
|
-
its([:swift_branch_code]) { is_expected.to eq(
|
418
|
+
context "with the sort code is hyphenated" do
|
419
|
+
let(:branch_code) { "20-00-00" }
|
420
|
+
its([:branch_code]) { is_expected.to eq("200000") }
|
421
|
+
its([:swift_branch_code]) { is_expected.to eq("200000") }
|
401
422
|
end
|
402
423
|
|
403
|
-
context
|
404
|
-
let(:branch_code) {
|
405
|
-
its([:branch_code]) { is_expected.to eq(
|
424
|
+
context "with the sort code spaced" do
|
425
|
+
let(:branch_code) { "20 00 00" }
|
426
|
+
its([:branch_code]) { is_expected.to eq("200000") }
|
406
427
|
end
|
407
428
|
|
408
|
-
context
|
409
|
-
let(:account_number) {
|
410
|
-
its([:account_number]) { is_expected.to eq(
|
411
|
-
its([:swift_account_number]) { is_expected.to eq(
|
429
|
+
context "with a short account number" do
|
430
|
+
let(:account_number) { "579135" }
|
431
|
+
its([:account_number]) { is_expected.to eq("00579135") }
|
432
|
+
its([:swift_account_number]) { is_expected.to eq("00579135") }
|
412
433
|
end
|
413
434
|
|
414
|
-
context
|
415
|
-
let(:account_number) {
|
435
|
+
context "with a too-short account number" do
|
436
|
+
let(:account_number) { "5678" }
|
416
437
|
its([:account_number]) { is_expected.to eq(account_number) }
|
417
438
|
end
|
418
439
|
|
419
|
-
context
|
420
|
-
let(:account_number) {
|
421
|
-
its([:account_number]) { is_expected.to eq(
|
440
|
+
context "with the account number spaced" do
|
441
|
+
let(:account_number) { "5577 9911" }
|
442
|
+
its([:account_number]) { is_expected.to eq("55779911") }
|
422
443
|
end
|
423
444
|
|
424
|
-
context
|
425
|
-
let(:account_number) {
|
426
|
-
its([:account_number]) { is_expected.to eq(
|
445
|
+
context "with the account number hyphenated" do
|
446
|
+
let(:account_number) { "5577-9911" }
|
447
|
+
its([:account_number]) { is_expected.to eq("55779911") }
|
427
448
|
end
|
428
449
|
|
429
|
-
context
|
450
|
+
context "without a branch code" do
|
430
451
|
let(:branch_code) { nil }
|
431
452
|
it { is_expected.to eq(local_details_with_swift) }
|
432
453
|
end
|
433
454
|
|
434
|
-
context
|
455
|
+
context "without a bank code" do
|
435
456
|
let(:bank_code) { nil }
|
436
457
|
it { is_expected.to eq(local_details_with_swift) }
|
437
458
|
|
438
|
-
context
|
459
|
+
context "with a BIC finder set" do
|
439
460
|
let(:bic_finder) { double }
|
440
461
|
before do
|
441
|
-
allow(bic_finder).to receive(:call).with(
|
442
|
-
and_return(
|
462
|
+
allow(bic_finder).to receive(:call).with("GB", "200000").
|
463
|
+
and_return("BARCGB22XXX")
|
443
464
|
Ibandit.bic_finder = bic_finder
|
444
465
|
end
|
445
466
|
after { Ibandit.bic_finder = nil }
|
446
467
|
|
447
|
-
its([:bank_code]) { is_expected.to eq(
|
448
|
-
its([:swift_bank_code]) { is_expected.to eq(
|
468
|
+
its([:bank_code]) { is_expected.to eq("BARC") }
|
469
|
+
its([:swift_bank_code]) { is_expected.to eq("BARC") }
|
449
470
|
end
|
450
471
|
end
|
451
472
|
|
452
|
-
context
|
453
|
-
let(:bank_code) {
|
473
|
+
context "with a bank code and BIC finder set" do
|
474
|
+
let(:bank_code) { "OVERRIDE" }
|
454
475
|
let(:bic_finder) { double }
|
455
476
|
before do
|
456
|
-
allow(bic_finder).to receive(:call).with(
|
457
|
-
and_return(
|
477
|
+
allow(bic_finder).to receive(:call).with("GB", "200000").
|
478
|
+
and_return("BARCGB22XXX")
|
458
479
|
Ibandit.bic_finder = bic_finder
|
459
480
|
end
|
460
481
|
after { Ibandit.bic_finder = nil }
|
461
482
|
|
462
|
-
its([:bank_code]) { is_expected.to eq(
|
483
|
+
its([:bank_code]) { is_expected.to eq("OVERRIDE") }
|
463
484
|
end
|
464
485
|
end
|
465
486
|
|
466
|
-
context
|
467
|
-
let(:country_code) {
|
468
|
-
let(:bank_code) {
|
469
|
-
let(:branch_code) {
|
470
|
-
let(:account_number) {
|
487
|
+
context "Greece" do
|
488
|
+
let(:country_code) { "GR" }
|
489
|
+
let(:bank_code) { "011" }
|
490
|
+
let(:branch_code) { "0125" }
|
491
|
+
let(:account_number) { "0000000012300695" }
|
471
492
|
|
472
493
|
it { is_expected.to eq(local_details_with_swift) }
|
473
494
|
|
474
|
-
context
|
495
|
+
context "without an account number" do
|
475
496
|
let(:account_number) { nil }
|
476
497
|
it { is_expected.to eq(local_details_with_swift) }
|
477
498
|
end
|
478
499
|
|
479
|
-
context
|
500
|
+
context "without a bank code" do
|
480
501
|
let(:bank_code) { nil }
|
481
502
|
it { is_expected.to eq(local_details_with_swift) }
|
482
503
|
end
|
483
504
|
|
484
|
-
context
|
505
|
+
context "without a branch code" do
|
485
506
|
let(:branch_code) { nil }
|
486
507
|
it { is_expected.to eq(local_details_with_swift) }
|
487
508
|
end
|
488
509
|
end
|
489
510
|
|
490
|
-
context
|
491
|
-
let(:country_code) {
|
492
|
-
let(:bank_code) {
|
493
|
-
let(:account_number) {
|
511
|
+
context "Croatia" do
|
512
|
+
let(:country_code) { "HR" }
|
513
|
+
let(:bank_code) { "1001005" }
|
514
|
+
let(:account_number) { "1863000160" }
|
494
515
|
|
495
516
|
it { is_expected.to eq(local_details_with_swift) }
|
496
517
|
|
497
|
-
context
|
518
|
+
context "with bank code in the account number" do
|
498
519
|
let(:bank_code) { nil }
|
499
520
|
let(:branch_code) { nil }
|
500
|
-
let(:account_number) {
|
521
|
+
let(:account_number) { "1001005-1863000160" }
|
501
522
|
|
502
|
-
its([:bank_code]) { is_expected.to eq(
|
503
|
-
its([:account_number]) { is_expected.to eq(
|
523
|
+
its([:bank_code]) { is_expected.to eq("1001005") }
|
524
|
+
its([:account_number]) { is_expected.to eq("1863000160") }
|
504
525
|
|
505
|
-
context
|
506
|
-
let(:account_number) {
|
526
|
+
context "with a badly formatted account number" do
|
527
|
+
let(:account_number) { "1863000160" }
|
507
528
|
it { is_expected.to eq(local_details_with_swift) }
|
508
529
|
end
|
509
530
|
end
|
510
531
|
|
511
|
-
context
|
532
|
+
context "without an account number" do
|
512
533
|
let(:account_number) { nil }
|
513
534
|
it { is_expected.to eq(local_details_with_swift) }
|
514
535
|
end
|
515
536
|
end
|
516
537
|
|
517
|
-
context
|
518
|
-
let(:country_code) {
|
519
|
-
let(:bank_code) {
|
520
|
-
let(:branch_code) {
|
521
|
-
let(:account_number) {
|
538
|
+
context "Hungary" do
|
539
|
+
let(:country_code) { "HU" }
|
540
|
+
let(:bank_code) { "117" }
|
541
|
+
let(:branch_code) { "7301" }
|
542
|
+
let(:account_number) { "61111101800000000" }
|
522
543
|
|
523
544
|
it { is_expected.to eq(local_details_with_swift) }
|
524
545
|
|
525
|
-
context
|
546
|
+
context "with bank and branch codes in the account number" do
|
526
547
|
let(:bank_code) { nil }
|
527
548
|
let(:branch_code) { nil }
|
528
549
|
|
529
|
-
context
|
530
|
-
let(:account_number) {
|
550
|
+
context "with a full account number" do
|
551
|
+
let(:account_number) { "11773016-11111018-00000000" }
|
531
552
|
|
532
|
-
its([:bank_code]) { is_expected.to eq(
|
533
|
-
its([:branch_code]) { is_expected.to eq(
|
534
|
-
its([:account_number]) { is_expected.to eq(
|
553
|
+
its([:bank_code]) { is_expected.to eq("117") }
|
554
|
+
its([:branch_code]) { is_expected.to eq("7301") }
|
555
|
+
its([:account_number]) { is_expected.to eq("61111101800000000") }
|
535
556
|
end
|
536
557
|
|
537
|
-
context
|
538
|
-
let(:account_number) {
|
558
|
+
context "with a short account number" do
|
559
|
+
let(:account_number) { "11773016-11111018" }
|
539
560
|
|
540
|
-
its([:bank_code]) { is_expected.to eq(
|
541
|
-
its([:branch_code]) { is_expected.to eq(
|
542
|
-
its([:account_number]) { is_expected.to eq(
|
561
|
+
its([:bank_code]) { is_expected.to eq("117") }
|
562
|
+
its([:branch_code]) { is_expected.to eq("7301") }
|
563
|
+
its([:account_number]) { is_expected.to eq("61111101800000000") }
|
543
564
|
end
|
544
565
|
|
545
|
-
context
|
546
|
-
let(:account_number) {
|
566
|
+
context "with an invalid length account number" do
|
567
|
+
let(:account_number) { "11773016-1111101" }
|
547
568
|
it { is_expected.to eq(local_details_with_swift) }
|
548
569
|
end
|
549
570
|
|
550
|
-
context
|
551
|
-
let(:account_number) {
|
552
|
-
let(:bank_code) {
|
571
|
+
context "with a bank code, too" do
|
572
|
+
let(:account_number) { "11773016-11111018" }
|
573
|
+
let(:bank_code) { "117" }
|
553
574
|
it { is_expected.to eq(local_details_with_swift) }
|
554
575
|
end
|
555
576
|
end
|
556
577
|
|
557
|
-
context
|
578
|
+
context "without an account number" do
|
558
579
|
let(:account_number) { nil }
|
559
580
|
it { is_expected.to eq(local_details_with_swift) }
|
560
581
|
end
|
561
582
|
end
|
562
583
|
|
563
|
-
context
|
564
|
-
let(:country_code) {
|
565
|
-
let(:bank_code) {
|
566
|
-
let(:branch_code) {
|
567
|
-
let(:account_number) {
|
584
|
+
context "Ireland" do
|
585
|
+
let(:country_code) { "IE" }
|
586
|
+
let(:bank_code) { "AIBK" }
|
587
|
+
let(:branch_code) { "931152" }
|
588
|
+
let(:account_number) { "12345678" }
|
568
589
|
|
569
590
|
it { is_expected.to eq(local_details_with_swift) }
|
570
591
|
|
571
|
-
context
|
572
|
-
let(:branch_code) {
|
573
|
-
its([:branch_code]) { is_expected.to eq(
|
592
|
+
context "with the sort code is hyphenated" do
|
593
|
+
let(:branch_code) { "93-11-52" }
|
594
|
+
its([:branch_code]) { is_expected.to eq("931152") }
|
574
595
|
end
|
575
596
|
|
576
|
-
context
|
577
|
-
let(:branch_code) {
|
578
|
-
its([:branch_code]) { is_expected.to eq(
|
597
|
+
context "with the sort code spaced" do
|
598
|
+
let(:branch_code) { "93 11 52" }
|
599
|
+
its([:branch_code]) { is_expected.to eq("931152") }
|
579
600
|
end
|
580
601
|
|
581
|
-
context
|
582
|
-
let(:account_number) {
|
583
|
-
its([:account_number]) { is_expected.to eq(
|
602
|
+
context "with a short account number" do
|
603
|
+
let(:account_number) { "579135" }
|
604
|
+
its([:account_number]) { is_expected.to eq("00579135") }
|
584
605
|
end
|
585
606
|
|
586
|
-
context
|
587
|
-
let(:account_number) {
|
607
|
+
context "with a too-short account number" do
|
608
|
+
let(:account_number) { "5678" }
|
588
609
|
its([:account_number]) { is_expected.to eq(account_number) }
|
589
610
|
end
|
590
611
|
|
591
|
-
context
|
592
|
-
let(:account_number) {
|
593
|
-
its([:account_number]) { is_expected.to eq(
|
612
|
+
context "with the account number spaced" do
|
613
|
+
let(:account_number) { "5577 9911" }
|
614
|
+
its([:account_number]) { is_expected.to eq("55779911") }
|
594
615
|
end
|
595
616
|
|
596
|
-
context
|
597
|
-
let(:account_number) {
|
598
|
-
its([:account_number]) { is_expected.to eq(
|
617
|
+
context "with the account number hyphenated" do
|
618
|
+
let(:account_number) { "5577-9911" }
|
619
|
+
its([:account_number]) { is_expected.to eq("55779911") }
|
599
620
|
end
|
600
621
|
|
601
|
-
context
|
622
|
+
context "without a branch code" do
|
602
623
|
let(:branch_code) { nil }
|
603
624
|
it { is_expected.to eq(local_details_with_swift) }
|
604
625
|
end
|
605
626
|
|
606
|
-
context
|
627
|
+
context "without a bank code" do
|
607
628
|
let(:bank_code) { nil }
|
608
629
|
it { is_expected.to eq(local_details_with_swift) }
|
609
630
|
|
610
|
-
context
|
631
|
+
context "with a BIC finder set" do
|
611
632
|
let(:bic_finder) { double }
|
612
633
|
before do
|
613
|
-
allow(bic_finder).to receive(:call).with(
|
614
|
-
and_return(
|
634
|
+
allow(bic_finder).to receive(:call).with("IE", "931152").
|
635
|
+
and_return("AIBKIE22XXX")
|
615
636
|
Ibandit.bic_finder = bic_finder
|
616
637
|
end
|
617
638
|
after { Ibandit.bic_finder = nil }
|
618
639
|
|
619
|
-
its([:bank_code]) { is_expected.to eq(
|
640
|
+
its([:bank_code]) { is_expected.to eq("AIBK") }
|
620
641
|
end
|
621
642
|
end
|
622
643
|
|
623
|
-
context
|
624
|
-
let(:bank_code) {
|
644
|
+
context "with a bank code and BIC finder set" do
|
645
|
+
let(:bank_code) { "OVERRIDE" }
|
625
646
|
let(:bic_finder) { double }
|
626
647
|
before do
|
627
|
-
allow(bic_finder).to receive(:call).with(
|
628
|
-
and_return(
|
648
|
+
allow(bic_finder).to receive(:call).with("IE", "931152").
|
649
|
+
and_return("AIBKIE22XXX")
|
629
650
|
Ibandit.bic_finder = bic_finder
|
630
651
|
end
|
631
652
|
after { Ibandit.bic_finder = nil }
|
632
653
|
|
633
|
-
its([:bank_code]) { is_expected.to eq(
|
654
|
+
its([:bank_code]) { is_expected.to eq("OVERRIDE") }
|
634
655
|
end
|
635
656
|
end
|
636
657
|
|
637
|
-
context
|
638
|
-
let(:country_code) {
|
639
|
-
let(:bank_code) {
|
640
|
-
let(:account_number) {
|
658
|
+
context "Iceland" do
|
659
|
+
let(:country_code) { "IS" }
|
660
|
+
let(:bank_code) { "311" }
|
661
|
+
let(:account_number) { "26-2468-460697-2049" }
|
641
662
|
|
642
|
-
its([:bank_code]) { is_expected.to eq(
|
643
|
-
its([:account_number]) { is_expected.to eq(
|
663
|
+
its([:bank_code]) { is_expected.to eq("0311") }
|
664
|
+
its([:account_number]) { is_expected.to eq("260024684606972049") }
|
644
665
|
|
645
|
-
context
|
666
|
+
context "with bank code in the account number" do
|
646
667
|
let(:bank_code) { nil }
|
647
|
-
let(:account_number) {
|
668
|
+
let(:account_number) { "311-26-2468-460697-2049" }
|
648
669
|
|
649
|
-
its([:bank_code]) { is_expected.to eq(
|
650
|
-
its([:account_number]) { is_expected.to eq(
|
670
|
+
its([:bank_code]) { is_expected.to eq("0311") }
|
671
|
+
its([:account_number]) { is_expected.to eq("260024684606972049") }
|
651
672
|
|
652
|
-
context
|
653
|
-
let(:account_number) {
|
673
|
+
context "and no hyphens" do
|
674
|
+
let(:account_number) { "0311260024684606972049" }
|
654
675
|
|
655
|
-
its([:bank_code]) { is_expected.to eq(
|
656
|
-
its([:account_number]) { is_expected.to eq(
|
676
|
+
its([:bank_code]) { is_expected.to eq("0311") }
|
677
|
+
its([:account_number]) { is_expected.to eq("260024684606972049") }
|
657
678
|
end
|
658
679
|
end
|
659
680
|
|
660
|
-
context
|
661
|
-
let(:account_number) {
|
681
|
+
context "with no hyphen in the kennitala" do
|
682
|
+
let(:account_number) { "26-2468-4606972049" }
|
662
683
|
|
663
|
-
its([:account_number]) { is_expected.to eq(
|
684
|
+
its([:account_number]) { is_expected.to eq("260024684606972049") }
|
664
685
|
end
|
665
686
|
|
666
|
-
context
|
667
|
-
let(:account_number) {
|
687
|
+
context "with a short kennitala" do
|
688
|
+
let(:account_number) { "26-2468-60697-2049" }
|
668
689
|
|
669
|
-
its([:account_number]) { is_expected.to eq(
|
690
|
+
its([:account_number]) { is_expected.to eq("260024680606972049") }
|
670
691
|
|
671
|
-
context
|
672
|
-
let(:account_number) {
|
673
|
-
its([:account_number]) { is_expected.to eq(
|
692
|
+
context "without a hyphen" do
|
693
|
+
let(:account_number) { "26-2468-606972049" }
|
694
|
+
its([:account_number]) { is_expected.to eq("260024680606972049") }
|
674
695
|
end
|
675
696
|
end
|
676
697
|
|
677
|
-
context
|
698
|
+
context "without an account number" do
|
678
699
|
let(:account_number) { nil }
|
679
700
|
it { is_expected.to eq(local_details_with_swift) }
|
680
701
|
end
|
681
702
|
end
|
682
703
|
|
683
|
-
context
|
684
|
-
let(:country_code) {
|
685
|
-
let(:bank_code) {
|
686
|
-
let(:branch_code) {
|
687
|
-
let(:account_number) {
|
704
|
+
context "Italy" do
|
705
|
+
let(:country_code) { "IT" }
|
706
|
+
let(:bank_code) { "05428" }
|
707
|
+
let(:branch_code) { "11101" }
|
708
|
+
let(:account_number) { "000000123456" }
|
688
709
|
|
689
710
|
it { is_expected.to eq(local_details_with_swift) }
|
690
711
|
|
691
|
-
context
|
692
|
-
before { local_details.merge!(check_digit:
|
712
|
+
context "with an explicit check digit" do
|
713
|
+
before { local_details.merge!(check_digit: "Y") }
|
693
714
|
it { is_expected.to eq(local_details_with_swift) }
|
694
715
|
end
|
695
716
|
|
696
|
-
context
|
697
|
-
let(:account_number) {
|
698
|
-
its([:account_number]) { is_expected.to eq(
|
717
|
+
context "with the account number not zero-padded" do
|
718
|
+
let(:account_number) { "123456" }
|
719
|
+
its([:account_number]) { is_expected.to eq("000000123456") }
|
699
720
|
end
|
700
721
|
|
701
|
-
context
|
722
|
+
context "without a bank code" do
|
702
723
|
let(:bank_code) { nil }
|
703
724
|
it { is_expected.to eq(local_details_with_swift) }
|
704
725
|
end
|
705
726
|
|
706
|
-
context
|
727
|
+
context "without a branch code" do
|
707
728
|
let(:branch_code) { nil }
|
708
729
|
it { is_expected.to eq(local_details_with_swift) }
|
709
730
|
end
|
710
731
|
|
711
|
-
context
|
732
|
+
context "without an account number" do
|
712
733
|
let(:account_number) { nil }
|
713
734
|
it { is_expected.to eq(local_details_with_swift) }
|
714
735
|
end
|
715
736
|
end
|
716
737
|
|
717
|
-
context
|
718
|
-
let(:country_code) {
|
719
|
-
let(:bank_code) {
|
720
|
-
let(:account_number) {
|
738
|
+
context "Lithuania" do
|
739
|
+
let(:country_code) { "LT" }
|
740
|
+
let(:bank_code) { "10000" }
|
741
|
+
let(:account_number) { "11101001000" }
|
721
742
|
|
722
743
|
it { is_expected.to eq(local_details_with_swift) }
|
723
744
|
|
724
|
-
context
|
745
|
+
context "without an account number" do
|
725
746
|
let(:account_number) { nil }
|
726
747
|
it { is_expected.to eq(local_details_with_swift) }
|
727
748
|
end
|
728
749
|
|
729
|
-
context
|
750
|
+
context "without a bank code" do
|
730
751
|
let(:bank_code) { nil }
|
731
752
|
it { is_expected.to eq(local_details_with_swift) }
|
732
753
|
end
|
733
754
|
end
|
734
755
|
|
735
|
-
context
|
736
|
-
let(:country_code) {
|
737
|
-
let(:bank_code) {
|
738
|
-
let(:account_number) {
|
756
|
+
context "Luxembourg" do
|
757
|
+
let(:country_code) { "LU" }
|
758
|
+
let(:bank_code) { "001" }
|
759
|
+
let(:account_number) { "9400644750000" }
|
739
760
|
|
740
761
|
it { is_expected.to eq(local_details_with_swift) }
|
741
762
|
|
742
|
-
context
|
763
|
+
context "without an account number" do
|
743
764
|
let(:account_number) { nil }
|
744
765
|
it { is_expected.to eq(local_details_with_swift) }
|
745
766
|
end
|
746
767
|
|
747
|
-
context
|
768
|
+
context "without a bank code" do
|
748
769
|
let(:bank_code) { nil }
|
749
770
|
it { is_expected.to eq(local_details_with_swift) }
|
750
771
|
end
|
751
772
|
end
|
752
773
|
|
753
|
-
context
|
754
|
-
let(:country_code) {
|
755
|
-
let(:bank_code) {
|
756
|
-
let(:account_number) {
|
774
|
+
context "Latvia" do
|
775
|
+
let(:country_code) { "LV" }
|
776
|
+
let(:bank_code) { "BANK" }
|
777
|
+
let(:account_number) { "1234567890123" }
|
757
778
|
|
758
779
|
it { is_expected.to eq(local_details_with_swift) }
|
759
780
|
|
760
|
-
context
|
781
|
+
context "without an account number" do
|
761
782
|
let(:account_number) { nil }
|
762
783
|
it { is_expected.to eq(local_details_with_swift) }
|
763
784
|
end
|
764
785
|
|
765
|
-
context
|
786
|
+
context "without a bank code" do
|
766
787
|
let(:bank_code) { nil }
|
767
788
|
it { is_expected.to eq(local_details_with_swift) }
|
768
789
|
end
|
769
790
|
end
|
770
791
|
|
771
|
-
context
|
772
|
-
let(:country_code) {
|
773
|
-
let(:bank_code) {
|
774
|
-
let(:branch_code) {
|
775
|
-
let(:account_number) {
|
792
|
+
context "Monaco" do
|
793
|
+
let(:country_code) { "MC" }
|
794
|
+
let(:bank_code) { "20041" }
|
795
|
+
let(:branch_code) { "01005" }
|
796
|
+
let(:account_number) { "0500013M02606" }
|
776
797
|
|
777
798
|
it { is_expected.to eq(local_details_with_swift) }
|
778
799
|
|
779
|
-
context
|
780
|
-
let(:account_number) {
|
781
|
-
its([:account_number]) { is_expected.to eq(
|
800
|
+
context "with the RIB key spaced in the account number" do
|
801
|
+
let(:account_number) { "0500013M026 06" }
|
802
|
+
its([:account_number]) { is_expected.to eq("0500013M02606") }
|
782
803
|
end
|
783
804
|
|
784
|
-
context
|
785
|
-
let(:account_number) {
|
786
|
-
its([:account_number]) { is_expected.to eq(
|
805
|
+
context "with the RIB key hyphenated in the account number" do
|
806
|
+
let(:account_number) { "0500013M026-06" }
|
807
|
+
its([:account_number]) { is_expected.to eq("0500013M02606") }
|
787
808
|
end
|
788
809
|
|
789
|
-
context
|
790
|
-
let(:account_number) {
|
810
|
+
context "with the RIB key missing" do
|
811
|
+
let(:account_number) { "0500013M026" }
|
791
812
|
it { is_expected.to eq(local_details_with_swift) }
|
792
813
|
end
|
793
814
|
|
794
|
-
context
|
815
|
+
context "without a bank code" do
|
795
816
|
let(:bank_code) { nil }
|
796
817
|
it { is_expected.to eq(local_details_with_swift) }
|
797
818
|
end
|
798
819
|
|
799
|
-
context
|
820
|
+
context "without a branch code" do
|
800
821
|
let(:branch_code) { nil }
|
801
822
|
it { is_expected.to eq(local_details_with_swift) }
|
802
823
|
end
|
803
824
|
|
804
|
-
context
|
825
|
+
context "without an account number" do
|
805
826
|
let(:account_number) { nil }
|
806
827
|
it { is_expected.to eq(local_details_with_swift) }
|
807
828
|
end
|
808
829
|
end
|
809
830
|
|
810
|
-
context
|
811
|
-
let(:country_code) {
|
812
|
-
let(:bank_code) {
|
813
|
-
let(:branch_code) {
|
814
|
-
let(:account_number) {
|
831
|
+
context "Malta" do
|
832
|
+
let(:country_code) { "MT" }
|
833
|
+
let(:bank_code) { "MMEB" }
|
834
|
+
let(:branch_code) { "44093" }
|
835
|
+
let(:account_number) { "000000009027293051" }
|
815
836
|
|
816
837
|
it { is_expected.to eq(local_details_with_swift) }
|
817
838
|
|
818
|
-
context
|
819
|
-
let(:account_number) {
|
820
|
-
its([:account_number]) { is_expected.to eq(
|
839
|
+
context "with the account number spaced" do
|
840
|
+
let(:account_number) { "9027 2930 51" }
|
841
|
+
its([:account_number]) { is_expected.to eq("000000009027293051") }
|
821
842
|
end
|
822
843
|
|
823
|
-
context
|
824
|
-
let(:account_number) {
|
825
|
-
its([:account_number]) { is_expected.to eq(
|
844
|
+
context "with the account number hyphenated" do
|
845
|
+
let(:account_number) { "9027-2930-51" }
|
846
|
+
its([:account_number]) { is_expected.to eq("000000009027293051") }
|
826
847
|
end
|
827
848
|
|
828
|
-
context
|
849
|
+
context "without a branch code" do
|
829
850
|
let(:branch_code) { nil }
|
830
851
|
it { is_expected.to eq(local_details_with_swift) }
|
831
852
|
end
|
832
853
|
|
833
|
-
context
|
854
|
+
context "without a bank code" do
|
834
855
|
let(:bank_code) { nil }
|
835
856
|
it { is_expected.to eq(local_details_with_swift) }
|
836
857
|
|
837
|
-
context
|
858
|
+
context "with a BIC finder set" do
|
838
859
|
let(:bic_finder) { double }
|
839
860
|
before do
|
840
|
-
allow(bic_finder).to receive(:call).with(
|
841
|
-
and_return(
|
861
|
+
allow(bic_finder).to receive(:call).with("MT", "44093").
|
862
|
+
and_return("MMEBMTMTXXX")
|
842
863
|
Ibandit.bic_finder = bic_finder
|
843
864
|
end
|
844
865
|
after { Ibandit.bic_finder = nil }
|
845
866
|
|
846
|
-
its([:bank_code]) { is_expected.to eq(
|
867
|
+
its([:bank_code]) { is_expected.to eq("MMEB") }
|
847
868
|
end
|
848
869
|
end
|
849
870
|
|
850
|
-
context
|
851
|
-
let(:bank_code) {
|
871
|
+
context "with a bank code and BIC finder set" do
|
872
|
+
let(:bank_code) { "OVERRIDE" }
|
852
873
|
let(:bic_finder) { double }
|
853
874
|
before do
|
854
|
-
allow(bic_finder).to receive(:call).with(
|
855
|
-
and_return(
|
875
|
+
allow(bic_finder).to receive(:call).with("MT", "44093").
|
876
|
+
and_return("MMEBMTMTXXX")
|
856
877
|
Ibandit.bic_finder = bic_finder
|
857
878
|
end
|
858
879
|
after { Ibandit.bic_finder = nil }
|
859
880
|
|
860
|
-
its([:bank_code]) { is_expected.to eq(
|
881
|
+
its([:bank_code]) { is_expected.to eq("OVERRIDE") }
|
861
882
|
end
|
862
883
|
end
|
863
884
|
|
864
|
-
context
|
865
|
-
let(:country_code) {
|
866
|
-
let(:bank_code) {
|
867
|
-
let(:account_number) {
|
885
|
+
context "Netherlands" do
|
886
|
+
let(:country_code) { "NL" }
|
887
|
+
let(:bank_code) { "ABNA" }
|
888
|
+
let(:account_number) { "0417164300" }
|
868
889
|
|
869
890
|
it { is_expected.to eq(local_details_with_swift) }
|
870
891
|
|
871
|
-
context
|
892
|
+
context "without a bank code" do
|
872
893
|
let(:bank_code) { nil }
|
873
894
|
it { is_expected.to eq(local_details_with_swift) }
|
874
895
|
end
|
875
896
|
|
876
|
-
context
|
897
|
+
context "without a branch code" do
|
877
898
|
let(:branch_code) { nil }
|
878
899
|
it { is_expected.to eq(local_details_with_swift) }
|
879
900
|
end
|
880
901
|
|
881
|
-
context
|
902
|
+
context "without an account number" do
|
882
903
|
let(:account_number) { nil }
|
883
904
|
it { is_expected.to eq(local_details_with_swift) }
|
884
905
|
end
|
885
906
|
|
886
|
-
context
|
887
|
-
let(:account_number) {
|
888
|
-
its([:account_number]) { is_expected.to eq(
|
907
|
+
context "with an account number that needs zero-padding" do
|
908
|
+
let(:account_number) { "417164300" }
|
909
|
+
its([:account_number]) { is_expected.to eq("0417164300") }
|
889
910
|
end
|
890
911
|
end
|
891
912
|
|
892
|
-
context
|
893
|
-
let(:country_code) {
|
894
|
-
let(:bank_code) {
|
895
|
-
let(:account_number) {
|
913
|
+
context "Norway" do
|
914
|
+
let(:country_code) { "NO" }
|
915
|
+
let(:bank_code) { "8601" }
|
916
|
+
let(:account_number) { "1117947" }
|
896
917
|
|
897
918
|
it { is_expected.to eq(local_details_with_swift) }
|
898
919
|
|
899
|
-
context
|
920
|
+
context "with bank and branch codes in the account number" do
|
900
921
|
let(:bank_code) { nil }
|
901
922
|
let(:branch_code) { nil }
|
902
|
-
let(:account_number) {
|
923
|
+
let(:account_number) { "8601.1117947" }
|
903
924
|
|
904
|
-
its([:bank_code]) { is_expected.to eq(
|
905
|
-
its([:account_number]) { is_expected.to eq(
|
925
|
+
its([:bank_code]) { is_expected.to eq("8601") }
|
926
|
+
its([:account_number]) { is_expected.to eq("1117947") }
|
906
927
|
end
|
907
928
|
|
908
|
-
context
|
929
|
+
context "without an account number" do
|
909
930
|
let(:account_number) { nil }
|
910
931
|
it { is_expected.to eq(local_details_with_swift) }
|
911
932
|
end
|
912
933
|
end
|
913
934
|
|
914
|
-
context
|
915
|
-
let(:country_code) {
|
916
|
-
let(:bank_code) {
|
917
|
-
let(:account_number) {
|
935
|
+
context "Poland" do
|
936
|
+
let(:country_code) { "PL" }
|
937
|
+
let(:bank_code) { "10201026" }
|
938
|
+
let(:account_number) { "0000042270201111" }
|
918
939
|
|
919
940
|
it { is_expected.to eq(local_details_with_swift) }
|
920
941
|
|
921
|
-
context
|
942
|
+
context "with a full length account number" do
|
922
943
|
let(:bank_code) { nil }
|
923
944
|
let(:branch_code) { nil }
|
924
|
-
let(:account_number) {
|
945
|
+
let(:account_number) { "60102010260000042270201111" }
|
925
946
|
|
926
|
-
its([:bank_code]) { is_expected.to eq(
|
927
|
-
its([:account_number]) { is_expected.to eq(
|
947
|
+
its([:bank_code]) { is_expected.to eq("10201026") }
|
948
|
+
its([:account_number]) { is_expected.to eq("0000042270201111") }
|
928
949
|
end
|
929
950
|
|
930
|
-
context
|
951
|
+
context "without an account number" do
|
931
952
|
let(:account_number) { nil }
|
932
953
|
it { is_expected.to eq(local_details_with_swift) }
|
933
954
|
end
|
934
955
|
end
|
935
956
|
|
936
|
-
context
|
937
|
-
let(:country_code) {
|
938
|
-
let(:bank_code) {
|
939
|
-
let(:branch_code) {
|
940
|
-
let(:account_number) {
|
957
|
+
context "Portugal" do
|
958
|
+
let(:country_code) { "PT" }
|
959
|
+
let(:bank_code) { "0002" }
|
960
|
+
let(:branch_code) { "0023" }
|
961
|
+
let(:account_number) { "0023843000578" }
|
941
962
|
|
942
963
|
it { is_expected.to eq(local_details_with_swift) }
|
943
964
|
|
944
|
-
context
|
965
|
+
context "without a bank code" do
|
945
966
|
let(:bank_code) { nil }
|
946
967
|
it { is_expected.to eq(local_details_with_swift) }
|
947
968
|
end
|
948
969
|
|
949
|
-
context
|
970
|
+
context "without a branch code" do
|
950
971
|
let(:branch_code) { nil }
|
951
972
|
it { is_expected.to eq(local_details_with_swift) }
|
952
973
|
end
|
953
974
|
|
954
|
-
context
|
975
|
+
context "without an account number" do
|
955
976
|
let(:account_number) { nil }
|
956
977
|
it { is_expected.to eq(local_details_with_swift) }
|
957
978
|
end
|
958
979
|
end
|
959
980
|
|
960
|
-
context
|
961
|
-
let(:country_code) {
|
962
|
-
let(:bank_code) {
|
963
|
-
let(:account_number) {
|
981
|
+
context "Romania" do
|
982
|
+
let(:country_code) { "RO" }
|
983
|
+
let(:bank_code) { "AAAA" }
|
984
|
+
let(:account_number) { "1B31007593840000" }
|
964
985
|
|
965
986
|
it { is_expected.to eq(local_details_with_swift) }
|
966
987
|
|
967
|
-
context
|
988
|
+
context "without an account number" do
|
968
989
|
let(:account_number) { nil }
|
969
990
|
it { is_expected.to eq(local_details_with_swift) }
|
970
991
|
end
|
971
992
|
|
972
|
-
context
|
993
|
+
context "without a bank code" do
|
973
994
|
let(:bank_code) { nil }
|
974
995
|
it { is_expected.to eq(local_details_with_swift) }
|
975
996
|
end
|
976
997
|
end
|
977
998
|
|
978
|
-
context
|
979
|
-
let(:country_code) {
|
999
|
+
context "Sweden" do
|
1000
|
+
let(:country_code) { "SE" }
|
980
1001
|
let(:bank_code) { nil }
|
981
|
-
let(:account_number) {
|
1002
|
+
let(:account_number) { "5013-1007270" }
|
982
1003
|
|
983
|
-
its([:account_number]) { is_expected.to eq(
|
984
|
-
its([:branch_code]) { is_expected.to eq(
|
985
|
-
its([:swift_bank_code]) { is_expected.to eq(
|
986
|
-
its([:swift_account_number]) { is_expected.to eq(
|
1004
|
+
its([:account_number]) { is_expected.to eq("1007270") }
|
1005
|
+
its([:branch_code]) { is_expected.to eq("5013") }
|
1006
|
+
its([:swift_bank_code]) { is_expected.to eq("500") }
|
1007
|
+
its([:swift_account_number]) { is_expected.to eq("00000050131007270") }
|
987
1008
|
|
988
|
-
context
|
1009
|
+
context "without an account number" do
|
989
1010
|
let(:account_number) { nil }
|
990
|
-
it { is_expected.to eq(
|
1011
|
+
it { is_expected.to eq(local_details_with_swift) }
|
991
1012
|
end
|
992
1013
|
|
993
|
-
context
|
994
|
-
let(:bank_code) {
|
1014
|
+
context "with a bank code" do
|
1015
|
+
let(:bank_code) { "501" }
|
995
1016
|
|
996
1017
|
# Doesn't do any conversion
|
997
|
-
its([:swift_bank_code]) { is_expected.to eq(
|
998
|
-
its([:bank_code]) { is_expected.to eq(
|
999
|
-
its([:account_number]) { is_expected.to eq(
|
1000
|
-
its([:swift_account_number]) { is_expected.to eq(
|
1018
|
+
its([:swift_bank_code]) { is_expected.to eq("501") }
|
1019
|
+
its([:bank_code]) { is_expected.to eq("501") }
|
1020
|
+
its([:account_number]) { is_expected.to eq("5013-1007270") }
|
1021
|
+
its([:swift_account_number]) { is_expected.to eq("5013-1007270") }
|
1001
1022
|
end
|
1002
1023
|
end
|
1003
1024
|
|
1004
|
-
context
|
1005
|
-
let(:country_code) {
|
1006
|
-
let(:bank_code) {
|
1007
|
-
let(:account_number) {
|
1025
|
+
context "Slovenia" do
|
1026
|
+
let(:country_code) { "SI" }
|
1027
|
+
let(:bank_code) { "19100" }
|
1028
|
+
let(:account_number) { "0000123438" }
|
1008
1029
|
|
1009
1030
|
it { is_expected.to eq(local_details_with_swift) }
|
1010
1031
|
|
1011
|
-
context
|
1012
|
-
let(:account_number) {
|
1013
|
-
its([:account_number]) { is_expected.to eq(
|
1032
|
+
context "with an account number which needs zero-padding" do
|
1033
|
+
let(:account_number) { "123438" }
|
1034
|
+
its([:account_number]) { is_expected.to eq("0000123438") }
|
1014
1035
|
end
|
1015
1036
|
|
1016
|
-
context
|
1037
|
+
context "without a bank code" do
|
1017
1038
|
let(:bank_code) { nil }
|
1018
1039
|
it { is_expected.to eq(local_details_with_swift) }
|
1019
1040
|
end
|
1020
1041
|
|
1021
|
-
context
|
1042
|
+
context "without an account number" do
|
1022
1043
|
let(:account_number) { nil }
|
1023
1044
|
it { is_expected.to eq(local_details_with_swift) }
|
1024
1045
|
end
|
1025
1046
|
end
|
1026
1047
|
|
1027
|
-
context
|
1028
|
-
let(:country_code) {
|
1029
|
-
let(:bank_code) {
|
1030
|
-
let(:account_number) {
|
1048
|
+
context "Slovak Republic" do
|
1049
|
+
let(:country_code) { "SK" }
|
1050
|
+
let(:bank_code) { "1200" }
|
1051
|
+
let(:account_number) { "0000198742637541" }
|
1031
1052
|
|
1032
1053
|
it { is_expected.to eq(local_details_with_swift) }
|
1033
1054
|
|
1034
|
-
context
|
1035
|
-
let(:prefix) {
|
1036
|
-
let(:account_number) {
|
1055
|
+
context "with an account number prefix" do
|
1056
|
+
let(:prefix) { "000019" }
|
1057
|
+
let(:account_number) { "8742637541" }
|
1037
1058
|
before { local_details.merge!(account_number_prefix: prefix) }
|
1038
1059
|
|
1039
|
-
its([:account_number]) { is_expected.to eq(
|
1060
|
+
its([:account_number]) { is_expected.to eq("0000198742637541") }
|
1040
1061
|
|
1041
|
-
context
|
1042
|
-
let(:prefix) {
|
1043
|
-
its([:account_number]) { is_expected.to eq(
|
1062
|
+
context "which needs zero-padding" do
|
1063
|
+
let(:prefix) { "19" }
|
1064
|
+
its([:account_number]) { is_expected.to eq("0000198742637541") }
|
1044
1065
|
end
|
1045
1066
|
end
|
1046
1067
|
|
1047
|
-
context
|
1068
|
+
context "without a bank code" do
|
1048
1069
|
let(:bank_code) { nil }
|
1049
1070
|
it { is_expected.to eq(local_details_with_swift) }
|
1050
1071
|
end
|
1051
1072
|
|
1052
|
-
context
|
1073
|
+
context "without an account number" do
|
1053
1074
|
let(:account_number) { nil }
|
1054
1075
|
it { is_expected.to eq(local_details_with_swift) }
|
1055
1076
|
end
|
1056
1077
|
end
|
1057
1078
|
|
1058
|
-
context
|
1059
|
-
let(:country_code) {
|
1060
|
-
let(:bank_code) {
|
1061
|
-
let(:branch_code) {
|
1062
|
-
let(:account_number) {
|
1079
|
+
context "San Marino" do
|
1080
|
+
let(:country_code) { "SM" }
|
1081
|
+
let(:bank_code) { "05428" }
|
1082
|
+
let(:branch_code) { "11101" }
|
1083
|
+
let(:account_number) { "000000123456" }
|
1063
1084
|
|
1064
1085
|
it { is_expected.to eq(local_details_with_swift) }
|
1065
1086
|
|
1066
|
-
context
|
1067
|
-
before { local_details.merge!(check_digit:
|
1087
|
+
context "with an explicit check digit" do
|
1088
|
+
before { local_details.merge!(check_digit: "Y") }
|
1068
1089
|
it { is_expected.to eq(local_details_with_swift) }
|
1069
1090
|
end
|
1070
1091
|
|
1071
|
-
context
|
1072
|
-
let(:account_number) {
|
1073
|
-
its([:account_number]) { is_expected.to eq(
|
1092
|
+
context "with the account number not zero-padded" do
|
1093
|
+
let(:account_number) { "123456" }
|
1094
|
+
its([:account_number]) { is_expected.to eq("000000123456") }
|
1074
1095
|
end
|
1075
1096
|
|
1076
|
-
context
|
1097
|
+
context "without a bank code" do
|
1077
1098
|
let(:bank_code) { nil }
|
1078
1099
|
it { is_expected.to eq(local_details_with_swift) }
|
1079
1100
|
end
|
1080
1101
|
|
1081
|
-
context
|
1102
|
+
context "without a branch code" do
|
1082
1103
|
let(:branch_code) { nil }
|
1083
1104
|
it { is_expected.to eq(local_details_with_swift) }
|
1084
1105
|
end
|
1085
1106
|
|
1086
|
-
context
|
1107
|
+
context "without an account number" do
|
1087
1108
|
let(:account_number) { nil }
|
1088
1109
|
it { is_expected.to eq(local_details_with_swift) }
|
1089
1110
|
end
|