ibandit 0.8.1 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -955,12 +955,12 @@ describe Ibandit::LocalDetailsCleaner do
955
955
 
956
956
  context 'Sweden' do
957
957
  let(:country_code) { 'SE' }
958
- let(:bank_code) { '501' }
958
+ let(:bank_code) { nil }
959
959
  let(:account_number) { '5013-1007270' }
960
960
 
961
961
  its([:account_number]) { is_expected.to eq('1007270') }
962
962
  its([:branch_code]) { is_expected.to eq('5013') }
963
- its([:swift_bank_code]) { is_expected.to eq('501') }
963
+ its([:swift_bank_code]) { is_expected.to eq('500') }
964
964
  its([:swift_account_number]) { is_expected.to eq('00000050131007270') }
965
965
 
966
966
  context 'without an account number' do
@@ -968,12 +968,14 @@ describe Ibandit::LocalDetailsCleaner do
968
968
  it { is_expected.to eq(local_details) }
969
969
  end
970
970
 
971
- context 'without a bank code' do
972
- let(:bank_code) { nil }
971
+ context 'with a bank code' do
972
+ let(:bank_code) { '501' }
973
973
 
974
- its([:swift_bank_code]) { is_expected.to eq('500') }
975
- its([:account_number]) { is_expected.to eq('1007270') }
976
- its([:swift_account_number]) { is_expected.to eq('00000050131007270') }
974
+ # Doesn't do any conversion
975
+ its([:swift_bank_code]) { is_expected.to eq('501') }
976
+ its([:bank_code]) { is_expected.to eq('501') }
977
+ its([:account_number]) { is_expected.to eq('5013-1007270') }
978
+ its([:swift_account_number]) { is_expected.to eq('5013-1007270') }
977
979
  end
978
980
  end
979
981
 
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Ibandit::SwedishDetailsConverter do
3
+ describe Ibandit::Sweden::LocalDetailsConverter do
4
4
  subject(:converter) do
5
5
  described_class.new(account_number: account_number,
6
6
  branch_code: branch_code)
@@ -56,15 +56,6 @@ describe Ibandit::SwedishDetailsConverter do
56
56
  its([:swift_account_number]) { is_expected.to eq('00000012810105723') }
57
57
  end
58
58
 
59
- context 'that has been zero-padded' do
60
- let(:account_number) { '000012810105723' }
61
-
62
- its([:account_number]) { is_expected.to eq('0105723') }
63
- its([:branch_code]) { is_expected.to eq('1281') }
64
- its([:swift_bank_code]) { is_expected.to eq('120') }
65
- its([:swift_account_number]) { is_expected.to eq('00000012810105723') }
66
- end
67
-
68
59
  context 'that needs the account number part to be zero-padded' do
69
60
  let(:account_number) { '1281-1' }
70
61
 
@@ -205,108 +196,4 @@ describe Ibandit::SwedishDetailsConverter do
205
196
  its([:swift_account_number]) { is_expected.to eq('00099603401258276') }
206
197
  end
207
198
  end
208
-
209
- describe '.valid_length?' do
210
- subject do
211
- described_class.valid_length?(bank_code: bank_code,
212
- account_number: account_number)
213
- end
214
-
215
- context 'without a bank code' do
216
- let(:account_number) { '12810105723' }
217
- let(:bank_code) { nil }
218
- it { is_expected.to eq(nil) }
219
- end
220
-
221
- context 'with an impossible bank code' do
222
- let(:account_number) { '12810105723' }
223
- let(:bank_code) { '500' }
224
- it { is_expected.to eq(nil) }
225
- end
226
-
227
- context 'with a normal type-1 account number' do
228
- let(:account_number) { '00000054391024039' }
229
- let(:bank_code) { '500' }
230
- it { is_expected.to eq(true) }
231
-
232
- context 'that has a 6 digit serial number' do
233
- let(:account_number) { '00000005439102403' }
234
- let(:bank_code) { '500' }
235
- it { is_expected.to eq(false) }
236
- end
237
-
238
- context 'that has an 8 digit serial number' do
239
- let(:account_number) { '00000543910240391' }
240
- let(:bank_code) { '500' }
241
- it { is_expected.to eq(false) }
242
- end
243
- end
244
-
245
- context 'without a Danske bank account' do
246
- let(:account_number) { '12810105723' }
247
- let(:bank_code) { '120' }
248
- it { is_expected.to eq(true) }
249
-
250
- context 'that has an 8 digit serial number' do
251
- let(:account_number) { '00000128101057231' }
252
- let(:bank_code) { '120' }
253
- it { is_expected.to eq(false) }
254
- end
255
-
256
- context 'that has a 6 digit serial number' do
257
- let(:account_number) { '00000001281010572' }
258
- let(:bank_code) { '120' }
259
- # This passes because it could be a 10 digit account number from the
260
- # clearing code range 9180-9189.
261
- it { is_expected.to eq(true) }
262
- end
263
- end
264
-
265
- context 'with a Handelsbanken account number' do
266
- let(:bank_code) { '600' }
267
- let(:account_number) { '00000000219161038' }
268
- it { is_expected.to eq(true) }
269
-
270
- context 'that is only 8 characters long' do
271
- let(:account_number) { '00000000021916103' }
272
- it { is_expected.to eq(true) }
273
- end
274
-
275
- context 'that is 10 characters long' do
276
- let(:account_number) { '00000002191610381' }
277
- it { is_expected.to eq(false) }
278
- end
279
- end
280
-
281
- context 'without a Nordea PlusGirot account number' do
282
- let(:bank_code) { '950' }
283
- let(:account_number) { '00099603401258276' }
284
- it { is_expected.to eq(true) }
285
- end
286
- end
287
-
288
- describe '.valid_bank_code?' do
289
- subject do
290
- described_class.valid_bank_code?(bank_code: bank_code,
291
- account_number: account_number)
292
- end
293
-
294
- context 'without a bank code' do
295
- let(:account_number) { '12810105723' }
296
- let(:bank_code) { nil }
297
- it { is_expected.to eq(false) }
298
- end
299
-
300
- context 'with an impossible bank code' do
301
- let(:account_number) { '12810105723' }
302
- let(:bank_code) { '500' }
303
- it { is_expected.to eq(false) }
304
- end
305
-
306
- context 'with a possible bank code' do
307
- let(:account_number) { '12810105723' }
308
- let(:bank_code) { '120' }
309
- it { is_expected.to eq(true) }
310
- end
311
- end
312
199
  end
@@ -0,0 +1,223 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ibandit::Sweden::Validator do
4
+ describe '.bank_code_exists_for_clearing_code?' do
5
+ subject do
6
+ described_class.bank_code_exists_for_clearing_code?(clearing_code)
7
+ end
8
+
9
+ context 'without a clearing code' do
10
+ let(:clearing_code) { nil }
11
+ it { is_expected.to eq(false) }
12
+ end
13
+
14
+ context 'with an impossible clearing code' do
15
+ let(:clearing_code) { '1001' }
16
+ it { is_expected.to eq(false) }
17
+ end
18
+
19
+ context 'with a possible clearing code' do
20
+ let(:clearing_code) { '1101' }
21
+ it { is_expected.to eq(true) }
22
+ end
23
+ end
24
+
25
+ describe '.valid_clearing_code_length?' do
26
+ subject { described_class.valid_clearing_code_length?(clearing_code) }
27
+
28
+ context 'without a clearing code' do
29
+ let(:clearing_code) { nil }
30
+ it { is_expected.to eq(nil) }
31
+ end
32
+
33
+ context 'with an impossible clearing code' do
34
+ let(:clearing_code) { '1001' }
35
+ it { is_expected.to eq(nil) }
36
+ end
37
+
38
+ context 'with a correct length 4-digit clearing code' do
39
+ let(:clearing_code) { '1101' }
40
+ it { is_expected.to eq(true) }
41
+ end
42
+
43
+ context 'with a correct length 5-digit clearing code' do
44
+ let(:clearing_code) { '80001' }
45
+ it { is_expected.to eq(true) }
46
+ end
47
+
48
+ context 'with an incorrect length 5-digit clearing code' do
49
+ let(:clearing_code) { '40001' }
50
+ it { is_expected.to eq(false) }
51
+ end
52
+ end
53
+
54
+ describe '.valid_serial_number_length?' do
55
+ subject do
56
+ described_class.valid_serial_number_length?(clearing_code: clearing_code,
57
+ serial_number: serial_number)
58
+ end
59
+
60
+ context 'without a clearing code' do
61
+ let(:clearing_code) { nil }
62
+ let(:serial_number) { '1234567' }
63
+ it { is_expected.to eq(nil) }
64
+ end
65
+
66
+ context 'with an impossible clearing code' do
67
+ let(:clearing_code) { '1001' }
68
+ let(:serial_number) { '1234567' }
69
+ it { is_expected.to eq(nil) }
70
+ end
71
+
72
+ context 'with a correct length serial number' do
73
+ let(:clearing_code) { '1101' }
74
+ let(:serial_number) { '1234567' }
75
+ it { is_expected.to eq(true) }
76
+ end
77
+
78
+ context 'with an incorrect length serial number' do
79
+ let(:clearing_code) { '1101' }
80
+ let(:serial_number) { '123456' }
81
+ it { is_expected.to eq(false) }
82
+ end
83
+
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
+ it { is_expected.to eq(true) }
88
+ end
89
+
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
+ it { is_expected.to eq(false) }
94
+ end
95
+ end
96
+
97
+ describe '.bank_code_exists?' do
98
+ subject { described_class.bank_code_exists?(bank_code) }
99
+
100
+ context 'without a bank code' do
101
+ let(:bank_code) { nil }
102
+ it { is_expected.to eq(false) }
103
+ end
104
+
105
+ context 'with an impossible bank code' do
106
+ let(:bank_code) { '123' }
107
+ it { is_expected.to eq(false) }
108
+ end
109
+
110
+ context 'with a possible bank code' do
111
+ let(:bank_code) { '120' }
112
+ it { is_expected.to eq(true) }
113
+ end
114
+ end
115
+
116
+ describe '.bank_code_possible_for_account_number?' do
117
+ subject do
118
+ described_class.bank_code_possible_for_account_number?(
119
+ bank_code: bank_code,
120
+ account_number: account_number
121
+ )
122
+ end
123
+
124
+ context 'without a bank code' do
125
+ let(:account_number) { '12810105723' }
126
+ let(:bank_code) { nil }
127
+ it { is_expected.to eq(nil) }
128
+ end
129
+
130
+ context 'with an impossible bank code' do
131
+ let(:account_number) { '12810105723' }
132
+ let(:bank_code) { '500' }
133
+ it { is_expected.to eq(false) }
134
+ end
135
+
136
+ context 'with a possible bank code' do
137
+ let(:account_number) { '12810105723' }
138
+ let(:bank_code) { '120' }
139
+ it { is_expected.to eq(true) }
140
+ end
141
+ end
142
+
143
+ describe '.account_number_length_valid_for_bank_code?' do
144
+ subject do
145
+ described_class.account_number_length_valid_for_bank_code?(
146
+ bank_code: bank_code,
147
+ account_number: account_number
148
+ )
149
+ end
150
+
151
+ context 'without a bank code' do
152
+ let(:account_number) { '12810105723' }
153
+ let(:bank_code) { nil }
154
+ it { is_expected.to eq(nil) }
155
+ end
156
+
157
+ context 'with an impossible bank code' do
158
+ let(:account_number) { '12810105723' }
159
+ let(:bank_code) { '500' }
160
+ it { is_expected.to eq(nil) }
161
+ end
162
+
163
+ context 'with a normal type-1 account number' do
164
+ let(:account_number) { '00000054391024039' }
165
+ let(:bank_code) { '500' }
166
+ it { is_expected.to eq(true) }
167
+
168
+ context 'that has a 6 digit serial number' do
169
+ let(:account_number) { '00000005439102403' }
170
+ let(:bank_code) { '500' }
171
+ it { is_expected.to eq(false) }
172
+ end
173
+
174
+ context 'that has an 8 digit serial number' do
175
+ let(:account_number) { '00000543910240391' }
176
+ let(:bank_code) { '500' }
177
+ it { is_expected.to eq(false) }
178
+ end
179
+ end
180
+
181
+ context 'with a Danske bank account' do
182
+ let(:account_number) { '12810105723' }
183
+ let(:bank_code) { '120' }
184
+ it { is_expected.to eq(true) }
185
+
186
+ context 'that has an 8 digit serial number' do
187
+ let(:account_number) { '00000128101057231' }
188
+ let(:bank_code) { '120' }
189
+ it { is_expected.to eq(false) }
190
+ end
191
+
192
+ context 'that has a 6 digit serial number' do
193
+ let(:account_number) { '00000001281010572' }
194
+ let(:bank_code) { '120' }
195
+ # This passes because it could be a 10 digit account number from the
196
+ # clearing code range 9180-9189.
197
+ it { is_expected.to eq(true) }
198
+ end
199
+ end
200
+
201
+ context 'with a Handelsbanken account number' do
202
+ let(:bank_code) { '600' }
203
+ let(:account_number) { '00000000219161038' }
204
+ it { is_expected.to eq(true) }
205
+
206
+ context 'that is only 8 characters long' do
207
+ let(:account_number) { '00000000021916103' }
208
+ it { is_expected.to eq(true) }
209
+ end
210
+
211
+ context 'that is 10 characters long' do
212
+ let(:account_number) { '00000002191610381' }
213
+ it { is_expected.to eq(false) }
214
+ end
215
+ end
216
+
217
+ context 'without a Nordea PlusGirot account number' do
218
+ let(:bank_code) { '950' }
219
+ let(:account_number) { '00099603401258276' }
220
+ it { is_expected.to eq(true) }
221
+ end
222
+ end
223
+ end
metadata CHANGED
@@ -1,97 +1,97 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ibandit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Grey Baker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-14 00:00:00.000000000 Z
11
+ date: 2015-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '3.3'
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
26
  version: '3.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec-its
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.2'
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
40
  version: '1.2'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rubocop
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ~>
46
46
  - !ruby/object:Gem::Version
47
47
  version: 0.33.0
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
54
  version: 0.33.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: sax-machine
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ~>
60
60
  - !ruby/object:Gem::Version
61
61
  version: '1.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
68
  version: '1.3'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: nokogiri
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ~>
74
74
  - !ruby/object:Gem::Version
75
75
  version: '1.6'
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
82
  version: '1.6'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: i18n
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ~>
88
88
  - !ruby/object:Gem::Version
89
89
  version: 0.7.0
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "~>"
94
+ - - ~>
95
95
  - !ruby/object:Gem::Version
96
96
  version: 0.7.0
97
97
  description: Ibandit is a Ruby library for manipulating and validating IBANs. It allows
@@ -103,10 +103,10 @@ executables: []
103
103
  extensions: []
104
104
  extra_rdoc_files: []
105
105
  files:
106
- - ".gitignore"
107
- - ".rubocop.yml"
108
- - ".rubocop_todo.yml"
109
- - ".travis.yml"
106
+ - .gitignore
107
+ - .rubocop.yml
108
+ - .rubocop_todo.yml
109
+ - .travis.yml
110
110
  - CHANGELOG.md
111
111
  - Gemfile
112
112
  - LICENSE
@@ -140,7 +140,9 @@ files:
140
140
  - lib/ibandit/local_details_cleaner.rb
141
141
  - lib/ibandit/pseudo_iban_assembler.rb
142
142
  - lib/ibandit/pseudo_iban_splitter.rb
143
- - lib/ibandit/swedish_details_converter.rb
143
+ - lib/ibandit/sweden/bank_lookup.rb
144
+ - lib/ibandit/sweden/local_details_converter.rb
145
+ - lib/ibandit/sweden/validator.rb
144
146
  - lib/ibandit/version.rb
145
147
  - spec/fixtures/germany_integration_test_cases.json
146
148
  - spec/fixtures/germany_unit_test_cases.json
@@ -151,7 +153,8 @@ files:
151
153
  - spec/ibandit/local_details_cleaner_spec.rb
152
154
  - spec/ibandit/pseudo_iban_assembler_spec.rb
153
155
  - spec/ibandit/pseudo_iban_splitter_spec.rb
154
- - spec/ibandit/swedish_details_converter_spec.rb
156
+ - spec/ibandit/sweden/local_details_converter_spec.rb
157
+ - spec/ibandit/sweden/validator_spec.rb
155
158
  - spec/spec_helper.rb
156
159
  homepage: https://github.com/gocardless/ibandit
157
160
  licenses:
@@ -163,17 +166,17 @@ require_paths:
163
166
  - lib
164
167
  required_ruby_version: !ruby/object:Gem::Requirement
165
168
  requirements:
166
- - - ">="
169
+ - - '>='
167
170
  - !ruby/object:Gem::Version
168
171
  version: '0'
169
172
  required_rubygems_version: !ruby/object:Gem::Requirement
170
173
  requirements:
171
- - - ">="
174
+ - - '>='
172
175
  - !ruby/object:Gem::Version
173
176
  version: '0'
174
177
  requirements: []
175
178
  rubyforge_project:
176
- rubygems_version: 2.4.6
179
+ rubygems_version: 2.2.2
177
180
  signing_key:
178
181
  specification_version: 4
179
182
  summary: Convert national banking details into IBANs, and vice-versa.