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,228 +1,228 @@
|
|
1
|
-
require
|
1
|
+
require "spec_helper"
|
2
2
|
|
3
3
|
describe Ibandit::Sweden::Validator do
|
4
|
-
describe
|
4
|
+
describe ".bank_code_exists_for_clearing_code?" do
|
5
5
|
subject do
|
6
6
|
described_class.bank_code_exists_for_clearing_code?(clearing_code)
|
7
7
|
end
|
8
8
|
|
9
|
-
context
|
9
|
+
context "without a clearing code" do
|
10
10
|
let(:clearing_code) { nil }
|
11
11
|
it { is_expected.to eq(false) }
|
12
12
|
end
|
13
13
|
|
14
|
-
context
|
15
|
-
let(:clearing_code) {
|
14
|
+
context "with an impossible clearing code" do
|
15
|
+
let(:clearing_code) { "1001" }
|
16
16
|
it { is_expected.to eq(false) }
|
17
17
|
end
|
18
18
|
|
19
|
-
context
|
20
|
-
let(:clearing_code) {
|
19
|
+
context "with a possible clearing code" do
|
20
|
+
let(:clearing_code) { "1101" }
|
21
21
|
it { is_expected.to eq(true) }
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
describe
|
25
|
+
describe ".valid_clearing_code_length?" do
|
26
26
|
subject { described_class.valid_clearing_code_length?(clearing_code) }
|
27
27
|
|
28
|
-
context
|
28
|
+
context "without a clearing code" do
|
29
29
|
let(:clearing_code) { nil }
|
30
30
|
it { is_expected.to eq(nil) }
|
31
31
|
end
|
32
32
|
|
33
|
-
context
|
34
|
-
let(:clearing_code) {
|
33
|
+
context "with an impossible clearing code" do
|
34
|
+
let(:clearing_code) { "1001" }
|
35
35
|
it { is_expected.to eq(nil) }
|
36
36
|
end
|
37
37
|
|
38
|
-
context
|
39
|
-
let(:clearing_code) {
|
38
|
+
context "with a correct length 4-digit clearing code" do
|
39
|
+
let(:clearing_code) { "1101" }
|
40
40
|
it { is_expected.to eq(true) }
|
41
41
|
end
|
42
42
|
|
43
|
-
context
|
44
|
-
let(:clearing_code) {
|
43
|
+
context "with a correct length 5-digit clearing code" do
|
44
|
+
let(:clearing_code) { "80001" }
|
45
45
|
it { is_expected.to eq(true) }
|
46
46
|
end
|
47
47
|
|
48
|
-
context
|
49
|
-
let(:clearing_code) {
|
48
|
+
context "with an incorrect length 5-digit clearing code" do
|
49
|
+
let(:clearing_code) { "40001" }
|
50
50
|
it { is_expected.to eq(false) }
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
describe
|
54
|
+
describe ".valid_serial_number_length?" do
|
55
55
|
subject do
|
56
56
|
described_class.valid_serial_number_length?(clearing_code: clearing_code,
|
57
57
|
serial_number: serial_number)
|
58
58
|
end
|
59
59
|
|
60
|
-
context
|
60
|
+
context "without a clearing code" do
|
61
61
|
let(:clearing_code) { nil }
|
62
|
-
let(:serial_number) {
|
62
|
+
let(:serial_number) { "1234567" }
|
63
63
|
it { is_expected.to eq(nil) }
|
64
64
|
end
|
65
65
|
|
66
|
-
context
|
67
|
-
let(:clearing_code) {
|
68
|
-
let(:serial_number) {
|
66
|
+
context "with an impossible clearing code" do
|
67
|
+
let(:clearing_code) { "1001" }
|
68
|
+
let(:serial_number) { "1234567" }
|
69
69
|
it { is_expected.to eq(nil) }
|
70
70
|
end
|
71
71
|
|
72
|
-
context
|
73
|
-
let(:clearing_code) {
|
74
|
-
let(:serial_number) {
|
72
|
+
context "with a correct length serial number" do
|
73
|
+
let(:clearing_code) { "1101" }
|
74
|
+
let(:serial_number) { "1234567" }
|
75
75
|
it { is_expected.to eq(true) }
|
76
76
|
end
|
77
77
|
|
78
|
-
context
|
79
|
-
let(:clearing_code) {
|
80
|
-
let(:serial_number) {
|
78
|
+
context "with an incorrect length serial number" do
|
79
|
+
let(:clearing_code) { "1101" }
|
80
|
+
let(:serial_number) { "123456" }
|
81
81
|
it { is_expected.to eq(false) }
|
82
82
|
end
|
83
83
|
|
84
|
-
context
|
85
|
-
let(:clearing_code) {
|
86
|
-
let(:serial_number) {
|
84
|
+
context "with a short serial number for a clearing code that zerofills" do
|
85
|
+
let(:clearing_code) { "9960" }
|
86
|
+
let(:serial_number) { "123456" }
|
87
87
|
it { is_expected.to eq(true) }
|
88
88
|
end
|
89
89
|
|
90
|
-
context
|
91
|
-
let(:clearing_code) {
|
92
|
-
let(:serial_number) {
|
90
|
+
context "with a long serial number for a clearing code that zerofills" do
|
91
|
+
let(:clearing_code) { "9960" }
|
92
|
+
let(:serial_number) { "12345678901" }
|
93
93
|
it { is_expected.to eq(false) }
|
94
94
|
end
|
95
95
|
|
96
|
-
context
|
97
|
-
let(:clearing_code) {
|
96
|
+
context "without a serial number" do
|
97
|
+
let(:clearing_code) { "9960" }
|
98
98
|
let(:serial_number) { nil }
|
99
99
|
it { is_expected.to eq(false) }
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
103
|
-
describe
|
103
|
+
describe ".bank_code_exists?" do
|
104
104
|
subject { described_class.bank_code_exists?(bank_code) }
|
105
105
|
|
106
|
-
context
|
106
|
+
context "without a bank code" do
|
107
107
|
let(:bank_code) { nil }
|
108
108
|
it { is_expected.to eq(false) }
|
109
109
|
end
|
110
110
|
|
111
|
-
context
|
112
|
-
let(:bank_code) {
|
111
|
+
context "with an impossible bank code" do
|
112
|
+
let(:bank_code) { "123" }
|
113
113
|
it { is_expected.to eq(false) }
|
114
114
|
end
|
115
115
|
|
116
|
-
context
|
117
|
-
let(:bank_code) {
|
116
|
+
context "with a possible bank code" do
|
117
|
+
let(:bank_code) { "120" }
|
118
118
|
it { is_expected.to eq(true) }
|
119
119
|
end
|
120
120
|
end
|
121
121
|
|
122
|
-
describe
|
122
|
+
describe ".bank_code_possible_for_account_number?" do
|
123
123
|
subject do
|
124
124
|
described_class.bank_code_possible_for_account_number?(
|
125
125
|
bank_code: bank_code,
|
126
|
-
account_number: account_number
|
126
|
+
account_number: account_number,
|
127
127
|
)
|
128
128
|
end
|
129
129
|
|
130
|
-
context
|
131
|
-
let(:account_number) {
|
130
|
+
context "without a bank code" do
|
131
|
+
let(:account_number) { "12810105723" }
|
132
132
|
let(:bank_code) { nil }
|
133
133
|
it { is_expected.to eq(nil) }
|
134
134
|
end
|
135
135
|
|
136
|
-
context
|
137
|
-
let(:account_number) {
|
138
|
-
let(:bank_code) {
|
136
|
+
context "with an impossible bank code" do
|
137
|
+
let(:account_number) { "12810105723" }
|
138
|
+
let(:bank_code) { "500" }
|
139
139
|
it { is_expected.to eq(false) }
|
140
140
|
end
|
141
141
|
|
142
|
-
context
|
143
|
-
let(:account_number) {
|
144
|
-
let(:bank_code) {
|
142
|
+
context "with a possible bank code" do
|
143
|
+
let(:account_number) { "12810105723" }
|
144
|
+
let(:bank_code) { "120" }
|
145
145
|
it { is_expected.to eq(true) }
|
146
146
|
end
|
147
147
|
end
|
148
148
|
|
149
|
-
describe
|
149
|
+
describe ".account_number_length_valid_for_bank_code?" do
|
150
150
|
subject do
|
151
151
|
described_class.account_number_length_valid_for_bank_code?(
|
152
152
|
bank_code: bank_code,
|
153
|
-
account_number: account_number
|
153
|
+
account_number: account_number,
|
154
154
|
)
|
155
155
|
end
|
156
156
|
|
157
|
-
context
|
158
|
-
let(:account_number) {
|
157
|
+
context "without a bank code" do
|
158
|
+
let(:account_number) { "12810105723" }
|
159
159
|
let(:bank_code) { nil }
|
160
160
|
it { is_expected.to eq(nil) }
|
161
161
|
end
|
162
162
|
|
163
|
-
context
|
164
|
-
let(:account_number) {
|
165
|
-
let(:bank_code) {
|
163
|
+
context "with an impossible bank code" do
|
164
|
+
let(:account_number) { "12810105723" }
|
165
|
+
let(:bank_code) { "500" }
|
166
166
|
it { is_expected.to eq(nil) }
|
167
167
|
end
|
168
168
|
|
169
|
-
context
|
170
|
-
let(:account_number) {
|
171
|
-
let(:bank_code) {
|
169
|
+
context "with a normal type-1 account number" do
|
170
|
+
let(:account_number) { "00000054391024039" }
|
171
|
+
let(:bank_code) { "500" }
|
172
172
|
it { is_expected.to eq(true) }
|
173
173
|
|
174
|
-
context
|
175
|
-
let(:account_number) {
|
176
|
-
let(:bank_code) {
|
174
|
+
context "that has a 6 digit serial number" do
|
175
|
+
let(:account_number) { "00000005439102403" }
|
176
|
+
let(:bank_code) { "500" }
|
177
177
|
it { is_expected.to eq(false) }
|
178
178
|
end
|
179
179
|
|
180
|
-
context
|
181
|
-
let(:account_number) {
|
182
|
-
let(:bank_code) {
|
180
|
+
context "that has an 8 digit serial number" do
|
181
|
+
let(:account_number) { "00000543910240391" }
|
182
|
+
let(:bank_code) { "500" }
|
183
183
|
it { is_expected.to eq(false) }
|
184
184
|
end
|
185
185
|
end
|
186
186
|
|
187
|
-
context
|
188
|
-
let(:account_number) {
|
189
|
-
let(:bank_code) {
|
187
|
+
context "with a Danske bank account" do
|
188
|
+
let(:account_number) { "12810105723" }
|
189
|
+
let(:bank_code) { "120" }
|
190
190
|
it { is_expected.to eq(true) }
|
191
191
|
|
192
|
-
context
|
193
|
-
let(:account_number) {
|
194
|
-
let(:bank_code) {
|
192
|
+
context "that has an 8 digit serial number" do
|
193
|
+
let(:account_number) { "00000128101057231" }
|
194
|
+
let(:bank_code) { "120" }
|
195
195
|
it { is_expected.to eq(false) }
|
196
196
|
end
|
197
197
|
|
198
|
-
context
|
199
|
-
let(:account_number) {
|
200
|
-
let(:bank_code) {
|
198
|
+
context "that has a 6 digit serial number" do
|
199
|
+
let(:account_number) { "00000001281010572" }
|
200
|
+
let(:bank_code) { "120" }
|
201
201
|
# This passes because it could be a 10 digit account number from the
|
202
202
|
# clearing code range 9180-9189.
|
203
203
|
it { is_expected.to eq(true) }
|
204
204
|
end
|
205
205
|
end
|
206
206
|
|
207
|
-
context
|
208
|
-
let(:bank_code) {
|
209
|
-
let(:account_number) {
|
207
|
+
context "with a Handelsbanken account number" do
|
208
|
+
let(:bank_code) { "600" }
|
209
|
+
let(:account_number) { "00000000219161038" }
|
210
210
|
it { is_expected.to eq(true) }
|
211
211
|
|
212
|
-
context
|
213
|
-
let(:account_number) {
|
212
|
+
context "that is only 8 characters long" do
|
213
|
+
let(:account_number) { "00000000021916103" }
|
214
214
|
it { is_expected.to eq(true) }
|
215
215
|
end
|
216
216
|
|
217
|
-
context
|
218
|
-
let(:account_number) {
|
217
|
+
context "that is 10 characters long" do
|
218
|
+
let(:account_number) { "00000002191610381" }
|
219
219
|
it { is_expected.to eq(false) }
|
220
220
|
end
|
221
221
|
end
|
222
222
|
|
223
|
-
context
|
224
|
-
let(:bank_code) {
|
225
|
-
let(:account_number) {
|
223
|
+
context "without a Nordea PlusGirot account number" do
|
224
|
+
let(:bank_code) { "950" }
|
225
|
+
let(:account_number) { "00099603401258276" }
|
226
226
|
it { is_expected.to eq(true) }
|
227
227
|
end
|
228
228
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require "ibandit"
|
2
|
+
require "rspec/its"
|
3
|
+
require "json"
|
4
4
|
|
5
5
|
RSpec.configure do |config|
|
6
6
|
config.mock_with(:rspec) { |mocks| mocks.verify_partial_doubles = true }
|
@@ -11,30 +11,30 @@ def json_fixture(filename)
|
|
11
11
|
JSON.parse(File.read("spec/fixtures/#{filename}.json"))
|
12
12
|
end
|
13
13
|
|
14
|
-
RSpec.shared_context
|
14
|
+
RSpec.shared_context "locale en", locale: :en do
|
15
15
|
around { |example| I18n.with_locale(:en) { example.run } }
|
16
16
|
end
|
17
17
|
|
18
|
-
RSpec.shared_context
|
18
|
+
RSpec.shared_context "locale fr", locale: :fr do
|
19
19
|
around { |example| I18n.with_locale(:fr) { example.run } }
|
20
20
|
end
|
21
21
|
|
22
|
-
RSpec.shared_context
|
22
|
+
RSpec.shared_context "locale de", locale: :de do
|
23
23
|
around { |example| I18n.with_locale(:de) { example.run } }
|
24
24
|
end
|
25
25
|
|
26
|
-
RSpec.shared_context
|
26
|
+
RSpec.shared_context "locale pt", locale: :pt do
|
27
27
|
around { |example| I18n.with_locale(:pt) { example.run } }
|
28
28
|
end
|
29
29
|
|
30
|
-
RSpec.shared_context
|
30
|
+
RSpec.shared_context "locale es", locale: :es do
|
31
31
|
around { |example| I18n.with_locale(:es) { example.run } }
|
32
32
|
end
|
33
33
|
|
34
|
-
RSpec.shared_context
|
34
|
+
RSpec.shared_context "locale it", locale: :it do
|
35
35
|
around { |example| I18n.with_locale(:it) { example.run } }
|
36
36
|
end
|
37
37
|
|
38
|
-
RSpec.shared_context
|
38
|
+
RSpec.shared_context "locale nl", locale: :nl do
|
39
39
|
around { |example| I18n.with_locale(:nl) { example.run } }
|
40
40
|
end
|
metadata
CHANGED
@@ -1,85 +1,113 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ibandit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
4
|
+
version: 0.11.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- GoCardless
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: nokogiri
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '1.6'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '1.6'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: pry
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0.10'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0.10'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: pry-nav
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.
|
47
|
+
version: '0.2'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.
|
54
|
+
version: '0.2'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '3.3'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '3.3'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: rspec-its
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '1.
|
75
|
+
version: '1.2'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '1.
|
82
|
+
version: '1.2'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.52.0
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.52.0
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: sax-machine
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '1.3'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '1.3'
|
83
111
|
- !ruby/object:Gem::Dependency
|
84
112
|
name: i18n
|
85
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -98,7 +126,7 @@ description: Ibandit is a Ruby library for manipulating and validating IBANs. It
|
|
98
126
|
you to construct an IBAN from national banking details; deconstruct an IBAN into
|
99
127
|
national banking details; and validate an IBAN's check digits and format.
|
100
128
|
email:
|
101
|
-
-
|
129
|
+
- developers@gocardless.com
|
102
130
|
executables: []
|
103
131
|
extensions: []
|
104
132
|
extra_rdoc_files: []
|
@@ -177,7 +205,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
177
205
|
version: '0'
|
178
206
|
requirements: []
|
179
207
|
rubyforge_project:
|
180
|
-
rubygems_version: 2.6.
|
208
|
+
rubygems_version: 2.6.13
|
181
209
|
signing_key:
|
182
210
|
specification_version: 4
|
183
211
|
summary: Convert national banking details into IBANs, and vice-versa.
|