ibandit 0.11.28 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +2 -5
- data/.rubocop_todo.yml +70 -15
- data/.travis.yml +4 -4
- data/CHANGELOG.md +7 -0
- data/Gemfile +1 -3
- data/README.md +6 -6
- data/data/structures.yml +4 -4
- data/ibandit.gemspec +2 -2
- data/lib/ibandit.rb +6 -3
- data/lib/ibandit/check_digit.rb +2 -0
- data/lib/ibandit/constants.rb +3 -1
- data/lib/ibandit/errors.rb +2 -0
- data/lib/ibandit/german_details_converter.rb +4 -1
- data/lib/ibandit/iban.rb +8 -4
- data/lib/ibandit/iban_assembler.rb +2 -0
- data/lib/ibandit/iban_splitter.rb +8 -7
- data/lib/ibandit/local_details_cleaner.rb +38 -35
- data/lib/ibandit/pseudo_iban_assembler.rb +5 -1
- data/lib/ibandit/pseudo_iban_splitter.rb +7 -1
- data/lib/ibandit/sweden/bank_lookup.rb +2 -0
- data/lib/ibandit/sweden/local_details_converter.rb +6 -2
- data/lib/ibandit/sweden/validator.rb +2 -0
- data/lib/ibandit/version.rb +3 -1
- data/spec/ibandit/constants_spec.rb +2 -0
- data/spec/ibandit/german_details_converter_spec.rb +9 -3
- data/spec/ibandit/iban_assembler_spec.rb +92 -3
- data/spec/ibandit/iban_spec.rb +197 -17
- data/spec/ibandit/iban_splitter_spec.rb +6 -0
- data/spec/ibandit/local_details_cleaner_spec.rb +135 -5
- data/spec/ibandit/pseudo_iban_assembler_spec.rb +2 -0
- data/spec/ibandit/pseudo_iban_splitter_spec.rb +2 -0
- data/spec/ibandit/structure_spec.rb +5 -3
- data/spec/ibandit/sweden/local_details_converter_spec.rb +3 -0
- data/spec/ibandit/sweden/validator_spec.rb +35 -0
- data/spec/spec_helper.rb +2 -0
- metadata +5 -6
@@ -1,10 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "spec_helper"
|
2
4
|
|
3
5
|
describe "structures.yml" do
|
4
|
-
|
5
|
-
|
6
|
+
structure_file = File.expand_path("../../data/structures.yml", __dir__)
|
7
|
+
structures = YAML.load_file(structure_file)
|
6
8
|
|
7
|
-
|
9
|
+
structures.each do |country, rules|
|
8
10
|
context country do
|
9
11
|
rules.each do |rule, value|
|
10
12
|
next unless rule =~ /_format$/
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "spec_helper"
|
2
4
|
|
3
5
|
describe Ibandit::Sweden::LocalDetailsConverter do
|
@@ -80,6 +82,7 @@ describe Ibandit::Sweden::LocalDetailsConverter do
|
|
80
82
|
its([:account_number]) { is_expected.to eq("1024039") }
|
81
83
|
its([:branch_code]) { is_expected.to eq("5439") }
|
82
84
|
its([:swift_bank_code]) { is_expected.to eq("500") }
|
85
|
+
|
83
86
|
its([:swift_account_number]) do
|
84
87
|
is_expected.to eq("00000054391024039")
|
85
88
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "spec_helper"
|
2
4
|
|
3
5
|
describe Ibandit::Sweden::Validator do
|
@@ -8,16 +10,19 @@ describe Ibandit::Sweden::Validator do
|
|
8
10
|
|
9
11
|
context "without a clearing code" do
|
10
12
|
let(:clearing_code) { nil }
|
13
|
+
|
11
14
|
it { is_expected.to eq(false) }
|
12
15
|
end
|
13
16
|
|
14
17
|
context "with an impossible clearing code" do
|
15
18
|
let(:clearing_code) { "1001" }
|
19
|
+
|
16
20
|
it { is_expected.to eq(false) }
|
17
21
|
end
|
18
22
|
|
19
23
|
context "with a possible clearing code" do
|
20
24
|
let(:clearing_code) { "1101" }
|
25
|
+
|
21
26
|
it { is_expected.to eq(true) }
|
22
27
|
end
|
23
28
|
end
|
@@ -27,26 +32,31 @@ describe Ibandit::Sweden::Validator do
|
|
27
32
|
|
28
33
|
context "without a clearing code" do
|
29
34
|
let(:clearing_code) { nil }
|
35
|
+
|
30
36
|
it { is_expected.to eq(nil) }
|
31
37
|
end
|
32
38
|
|
33
39
|
context "with an impossible clearing code" do
|
34
40
|
let(:clearing_code) { "1001" }
|
41
|
+
|
35
42
|
it { is_expected.to eq(nil) }
|
36
43
|
end
|
37
44
|
|
38
45
|
context "with a correct length 4-digit clearing code" do
|
39
46
|
let(:clearing_code) { "1101" }
|
47
|
+
|
40
48
|
it { is_expected.to eq(true) }
|
41
49
|
end
|
42
50
|
|
43
51
|
context "with a correct length 5-digit clearing code" do
|
44
52
|
let(:clearing_code) { "80001" }
|
53
|
+
|
45
54
|
it { is_expected.to eq(true) }
|
46
55
|
end
|
47
56
|
|
48
57
|
context "with an incorrect length 5-digit clearing code" do
|
49
58
|
let(:clearing_code) { "40001" }
|
59
|
+
|
50
60
|
it { is_expected.to eq(false) }
|
51
61
|
end
|
52
62
|
end
|
@@ -60,42 +70,49 @@ describe Ibandit::Sweden::Validator do
|
|
60
70
|
context "without a clearing code" do
|
61
71
|
let(:clearing_code) { nil }
|
62
72
|
let(:serial_number) { "1234567" }
|
73
|
+
|
63
74
|
it { is_expected.to eq(nil) }
|
64
75
|
end
|
65
76
|
|
66
77
|
context "with an impossible clearing code" do
|
67
78
|
let(:clearing_code) { "1001" }
|
68
79
|
let(:serial_number) { "1234567" }
|
80
|
+
|
69
81
|
it { is_expected.to eq(nil) }
|
70
82
|
end
|
71
83
|
|
72
84
|
context "with a correct length serial number" do
|
73
85
|
let(:clearing_code) { "1101" }
|
74
86
|
let(:serial_number) { "1234567" }
|
87
|
+
|
75
88
|
it { is_expected.to eq(true) }
|
76
89
|
end
|
77
90
|
|
78
91
|
context "with an incorrect length serial number" do
|
79
92
|
let(:clearing_code) { "1101" }
|
80
93
|
let(:serial_number) { "123456" }
|
94
|
+
|
81
95
|
it { is_expected.to eq(false) }
|
82
96
|
end
|
83
97
|
|
84
98
|
context "with a short serial number for a clearing code that zerofills" do
|
85
99
|
let(:clearing_code) { "9960" }
|
86
100
|
let(:serial_number) { "123456" }
|
101
|
+
|
87
102
|
it { is_expected.to eq(true) }
|
88
103
|
end
|
89
104
|
|
90
105
|
context "with a long serial number for a clearing code that zerofills" do
|
91
106
|
let(:clearing_code) { "9960" }
|
92
107
|
let(:serial_number) { "12345678901" }
|
108
|
+
|
93
109
|
it { is_expected.to eq(false) }
|
94
110
|
end
|
95
111
|
|
96
112
|
context "without a serial number" do
|
97
113
|
let(:clearing_code) { "9960" }
|
98
114
|
let(:serial_number) { nil }
|
115
|
+
|
99
116
|
it { is_expected.to eq(false) }
|
100
117
|
end
|
101
118
|
end
|
@@ -105,16 +122,19 @@ describe Ibandit::Sweden::Validator do
|
|
105
122
|
|
106
123
|
context "without a bank code" do
|
107
124
|
let(:bank_code) { nil }
|
125
|
+
|
108
126
|
it { is_expected.to eq(false) }
|
109
127
|
end
|
110
128
|
|
111
129
|
context "with an impossible bank code" do
|
112
130
|
let(:bank_code) { "123" }
|
131
|
+
|
113
132
|
it { is_expected.to eq(false) }
|
114
133
|
end
|
115
134
|
|
116
135
|
context "with a possible bank code" do
|
117
136
|
let(:bank_code) { "120" }
|
137
|
+
|
118
138
|
it { is_expected.to eq(true) }
|
119
139
|
end
|
120
140
|
end
|
@@ -130,18 +150,21 @@ describe Ibandit::Sweden::Validator do
|
|
130
150
|
context "without a bank code" do
|
131
151
|
let(:account_number) { "12810105723" }
|
132
152
|
let(:bank_code) { nil }
|
153
|
+
|
133
154
|
it { is_expected.to eq(nil) }
|
134
155
|
end
|
135
156
|
|
136
157
|
context "with an impossible bank code" do
|
137
158
|
let(:account_number) { "12810105723" }
|
138
159
|
let(:bank_code) { "500" }
|
160
|
+
|
139
161
|
it { is_expected.to eq(false) }
|
140
162
|
end
|
141
163
|
|
142
164
|
context "with a possible bank code" do
|
143
165
|
let(:account_number) { "12810105723" }
|
144
166
|
let(:bank_code) { "120" }
|
167
|
+
|
145
168
|
it { is_expected.to eq(true) }
|
146
169
|
end
|
147
170
|
end
|
@@ -157,29 +180,34 @@ describe Ibandit::Sweden::Validator do
|
|
157
180
|
context "without a bank code" do
|
158
181
|
let(:account_number) { "12810105723" }
|
159
182
|
let(:bank_code) { nil }
|
183
|
+
|
160
184
|
it { is_expected.to eq(nil) }
|
161
185
|
end
|
162
186
|
|
163
187
|
context "with an impossible bank code" do
|
164
188
|
let(:account_number) { "12810105723" }
|
165
189
|
let(:bank_code) { "500" }
|
190
|
+
|
166
191
|
it { is_expected.to eq(nil) }
|
167
192
|
end
|
168
193
|
|
169
194
|
context "with a normal type-1 account number" do
|
170
195
|
let(:account_number) { "00000054391024039" }
|
171
196
|
let(:bank_code) { "500" }
|
197
|
+
|
172
198
|
it { is_expected.to eq(true) }
|
173
199
|
|
174
200
|
context "that has a 6 digit serial number" do
|
175
201
|
let(:account_number) { "00000005439102403" }
|
176
202
|
let(:bank_code) { "500" }
|
203
|
+
|
177
204
|
it { is_expected.to eq(false) }
|
178
205
|
end
|
179
206
|
|
180
207
|
context "that has an 8 digit serial number" do
|
181
208
|
let(:account_number) { "00000543910240391" }
|
182
209
|
let(:bank_code) { "500" }
|
210
|
+
|
183
211
|
it { is_expected.to eq(false) }
|
184
212
|
end
|
185
213
|
end
|
@@ -187,11 +215,13 @@ describe Ibandit::Sweden::Validator do
|
|
187
215
|
context "with a Danske bank account" do
|
188
216
|
let(:account_number) { "12810105723" }
|
189
217
|
let(:bank_code) { "120" }
|
218
|
+
|
190
219
|
it { is_expected.to eq(true) }
|
191
220
|
|
192
221
|
context "that has an 8 digit serial number" do
|
193
222
|
let(:account_number) { "00000128101057231" }
|
194
223
|
let(:bank_code) { "120" }
|
224
|
+
|
195
225
|
it { is_expected.to eq(false) }
|
196
226
|
end
|
197
227
|
|
@@ -200,6 +230,7 @@ describe Ibandit::Sweden::Validator do
|
|
200
230
|
let(:bank_code) { "120" }
|
201
231
|
# This passes because it could be a 10 digit account number from the
|
202
232
|
# clearing code range 9180-9189.
|
233
|
+
|
203
234
|
it { is_expected.to eq(true) }
|
204
235
|
end
|
205
236
|
end
|
@@ -207,15 +238,18 @@ describe Ibandit::Sweden::Validator do
|
|
207
238
|
context "with a Handelsbanken account number" do
|
208
239
|
let(:bank_code) { "600" }
|
209
240
|
let(:account_number) { "00000000219161038" }
|
241
|
+
|
210
242
|
it { is_expected.to eq(true) }
|
211
243
|
|
212
244
|
context "that is only 8 characters long" do
|
213
245
|
let(:account_number) { "00000000021916103" }
|
246
|
+
|
214
247
|
it { is_expected.to eq(true) }
|
215
248
|
end
|
216
249
|
|
217
250
|
context "that is 10 characters long" do
|
218
251
|
let(:account_number) { "00000002191610381" }
|
252
|
+
|
219
253
|
it { is_expected.to eq(false) }
|
220
254
|
end
|
221
255
|
end
|
@@ -223,6 +257,7 @@ describe Ibandit::Sweden::Validator do
|
|
223
257
|
context "without a Nordea PlusGirot account number" do
|
224
258
|
let(:bank_code) { "950" }
|
225
259
|
let(:account_number) { "00099603401258276" }
|
260
|
+
|
226
261
|
it { is_expected.to eq(true) }
|
227
262
|
end
|
228
263
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ibandit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GoCardless
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-10-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -86,14 +86,14 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.
|
89
|
+
version: 0.70.0
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0.
|
96
|
+
version: 0.70.0
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: sax-machine
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -209,8 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
209
209
|
- !ruby/object:Gem::Version
|
210
210
|
version: '0'
|
211
211
|
requirements: []
|
212
|
-
|
213
|
-
rubygems_version: 2.5.2.3
|
212
|
+
rubygems_version: 3.0.2
|
214
213
|
signing_key:
|
215
214
|
specification_version: 4
|
216
215
|
summary: Convert national banking details into IBANs, and vice-versa.
|