ibandit 0.11.6 → 0.11.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,37 +1,37 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Ibandit::PseudoIBANAssembler do
4
4
  subject(:pseudo_iban) { described_class.new(local_details).assemble }
5
5
 
6
- context 'for Sweden' do
7
- context 'with valid parameters' do
6
+ context "for Sweden" do
7
+ context "with valid parameters" do
8
8
  let(:local_details) do
9
9
  {
10
- country_code: 'SE',
11
- branch_code: '1281',
12
- account_number: '0105723'
10
+ country_code: "SE",
11
+ branch_code: "1281",
12
+ account_number: "0105723",
13
13
  }
14
14
  end
15
15
 
16
- it { is_expected.to eq('SEZZX1281XXX0105723') }
16
+ it { is_expected.to eq("SEZZX1281XXX0105723") }
17
17
  end
18
18
 
19
- context 'without a branch code' do
19
+ context "without a branch code" do
20
20
  let(:local_details) do
21
21
  {
22
- country_code: 'SE',
23
- account_number: '0105723'
22
+ country_code: "SE",
23
+ account_number: "0105723",
24
24
  }
25
25
  end
26
26
 
27
27
  it { is_expected.to be_nil }
28
28
  end
29
29
 
30
- context 'without an account number' do
30
+ context "without an account number" do
31
31
  let(:local_details) do
32
32
  {
33
- country_code: 'SE',
34
- branch_code: '1281'
33
+ country_code: "SE",
34
+ branch_code: "1281",
35
35
  }
36
36
  end
37
37
 
@@ -39,13 +39,49 @@ describe Ibandit::PseudoIBANAssembler do
39
39
  end
40
40
  end
41
41
 
42
- context 'for a country that does not have pseudo-IBANs' do
42
+ context "for Australia" do
43
+ context "with valid parameters" do
44
+ let(:local_details) do
45
+ {
46
+ country_code: "AU",
47
+ branch_code: "123456",
48
+ account_number: "123456789",
49
+ }
50
+ end
51
+
52
+ it { is_expected.to eq("AUZZ123456123456789") }
53
+ end
54
+
55
+ context "without a branch code" do
56
+ let(:local_details) do
57
+ {
58
+ country_code: "AU",
59
+ account_number: "123456789",
60
+ }
61
+ end
62
+
63
+ it { is_expected.to be_nil }
64
+ end
65
+
66
+ context "without an account number" do
67
+ let(:local_details) do
68
+ {
69
+ country_code: "AU",
70
+ branch_code: "123456",
71
+ }
72
+ end
73
+
74
+ it { is_expected.to be_nil }
75
+ end
76
+ end
77
+
78
+ context "for a country that does not have pseudo-IBANs" do
43
79
  let(:local_details) do
44
80
  {
45
- country_code: 'GB',
46
- bank_code: 'WEST',
47
- branch_code: '123456',
48
- account_number: '98765432'
81
+ country_code: "GB",
82
+ bank_code: "WEST",
83
+ branch_code: "123456",
84
+ account_number: "98765432",
49
85
  }
50
86
  end
51
87
 
@@ -1,36 +1,27 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Ibandit::PseudoIBANSplitter do
4
4
  subject(:splitter) { described_class.new(pseudo_iban) }
5
5
 
6
- describe '#split' do
6
+ describe "#split" do
7
7
  subject(:local_details) { splitter.split }
8
8
 
9
- context 'for a valid pseudo-IBAN' do
10
- let(:pseudo_iban) { 'SEZZX1281XXX0105723' }
9
+ context "for a swedish pseudo-IBAN" do
10
+ let(:pseudo_iban) { "SEZZX1281XXX0105723" }
11
11
 
12
- its([:country_code]) { is_expected.to eq('SE') }
12
+ its([:country_code]) { is_expected.to eq("SE") }
13
13
  its([:bank_code]) { is_expected.to be_nil }
14
- its([:branch_code]) { is_expected.to eq('1281') }
15
- its([:account_number]) { is_expected.to eq('0105723') }
14
+ its([:branch_code]) { is_expected.to eq("1281") }
15
+ its([:account_number]) { is_expected.to eq("0105723") }
16
16
  end
17
17
 
18
- context 'for an unsupported country' do
19
- let(:pseudo_iban) { 'GBZZX1281XXX0105723' }
18
+ context "for an australian pseudo-IBAN" do
19
+ let(:pseudo_iban) { "AUZZ123456123456789" }
20
20
 
21
- it { is_expected.to be_nil }
22
- end
23
-
24
- context 'with invalid check digits' do
25
- let(:pseudo_iban) { 'SEYYX1281XXX0105723' }
26
-
27
- it { is_expected.to be_nil }
28
- end
29
-
30
- context 'with the wrong length' do
31
- let(:pseudo_iban) { 'SEYYX1281XXX010572' }
32
-
33
- it { is_expected.to be_nil }
21
+ its([:country_code]) { is_expected.to eq("AU") }
22
+ its([:bank_code]) { is_expected.to be_nil }
23
+ its([:branch_code]) { is_expected.to eq("123456") }
24
+ its([:account_number]) { is_expected.to eq("123456789") }
34
25
  end
35
26
  end
36
27
  end
@@ -1,7 +1,7 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
- describe 'structures.yml' do
4
- FILE = File.expand_path('../../../data/structures.yml', __FILE__)
3
+ describe "structures.yml" do
4
+ FILE = File.expand_path("../../../data/structures.yml", __FILE__)
5
5
  STRUCTURES = YAML.load_file(FILE)
6
6
 
7
7
  STRUCTURES.each do |country, rules|
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Ibandit::Sweden::LocalDetailsConverter do
4
4
  subject(:converter) do
@@ -8,202 +8,202 @@ describe Ibandit::Sweden::LocalDetailsConverter do
8
8
 
9
9
  let(:branch_code) { nil }
10
10
 
11
- describe '.convert' do
11
+ describe ".convert" do
12
12
  subject { converter.convert }
13
13
 
14
- context 'with a type-1 account number' do
15
- let(:account_number) { '12810105723' }
14
+ context "with a type-1 account number" do
15
+ let(:account_number) { "12810105723" }
16
16
 
17
- its([:account_number]) { is_expected.to eq('0105723') }
18
- its([:branch_code]) { is_expected.to eq('1281') }
19
- its([:swift_bank_code]) { is_expected.to eq('120') }
20
- its([:swift_account_number]) { is_expected.to eq('00000012810105723') }
17
+ its([:account_number]) { is_expected.to eq("0105723") }
18
+ its([:branch_code]) { is_expected.to eq("1281") }
19
+ its([:swift_bank_code]) { is_expected.to eq("120") }
20
+ its([:swift_account_number]) { is_expected.to eq("00000012810105723") }
21
21
 
22
- context 'that includes hyphens' do
23
- let(:account_number) { '1281-0105723' }
22
+ context "that includes hyphens" do
23
+ let(:account_number) { "1281-0105723" }
24
24
 
25
- its([:account_number]) { is_expected.to eq('0105723') }
26
- its([:branch_code]) { is_expected.to eq('1281') }
27
- its([:swift_bank_code]) { is_expected.to eq('120') }
28
- its([:swift_account_number]) { is_expected.to eq('00000012810105723') }
25
+ its([:account_number]) { is_expected.to eq("0105723") }
26
+ its([:branch_code]) { is_expected.to eq("1281") }
27
+ its([:swift_bank_code]) { is_expected.to eq("120") }
28
+ its([:swift_account_number]) { is_expected.to eq("00000012810105723") }
29
29
  end
30
30
 
31
- context 'with a separate branch code' do
32
- let(:branch_code) { '1281' }
33
- let(:account_number) { '0105723' }
31
+ context "with a separate branch code" do
32
+ let(:branch_code) { "1281" }
33
+ let(:account_number) { "0105723" }
34
34
 
35
- its([:account_number]) { is_expected.to eq('0105723') }
36
- its([:branch_code]) { is_expected.to eq('1281') }
37
- its([:swift_bank_code]) { is_expected.to eq('120') }
38
- its([:swift_account_number]) { is_expected.to eq('00000012810105723') }
35
+ its([:account_number]) { is_expected.to eq("0105723") }
36
+ its([:branch_code]) { is_expected.to eq("1281") }
37
+ its([:swift_bank_code]) { is_expected.to eq("120") }
38
+ its([:swift_account_number]) { is_expected.to eq("00000012810105723") }
39
39
  end
40
40
 
41
- context 'that includes spaces' do
42
- let(:account_number) { '1281 0105723' }
41
+ context "that includes spaces" do
42
+ let(:account_number) { "1281 0105723" }
43
43
 
44
- its([:account_number]) { is_expected.to eq('0105723') }
45
- its([:branch_code]) { is_expected.to eq('1281') }
46
- its([:swift_bank_code]) { is_expected.to eq('120') }
47
- its([:swift_account_number]) { is_expected.to eq('00000012810105723') }
44
+ its([:account_number]) { is_expected.to eq("0105723") }
45
+ its([:branch_code]) { is_expected.to eq("1281") }
46
+ its([:swift_bank_code]) { is_expected.to eq("120") }
47
+ its([:swift_account_number]) { is_expected.to eq("00000012810105723") }
48
48
  end
49
49
 
50
- context 'that includes full stops' do
51
- let(:account_number) { '1281.010.572.3' }
50
+ context "that includes full stops" do
51
+ let(:account_number) { "1281.010.572.3" }
52
52
 
53
- its([:account_number]) { is_expected.to eq('0105723') }
54
- its([:branch_code]) { is_expected.to eq('1281') }
55
- its([:swift_bank_code]) { is_expected.to eq('120') }
56
- its([:swift_account_number]) { is_expected.to eq('00000012810105723') }
53
+ its([:account_number]) { is_expected.to eq("0105723") }
54
+ its([:branch_code]) { is_expected.to eq("1281") }
55
+ its([:swift_bank_code]) { is_expected.to eq("120") }
56
+ its([:swift_account_number]) { is_expected.to eq("00000012810105723") }
57
57
  end
58
58
 
59
- context 'that needs the account number part to be zero-padded' do
60
- let(:account_number) { '1281-1' }
59
+ context "that needs the account number part to be zero-padded" do
60
+ let(:account_number) { "1281-1" }
61
61
 
62
- its([:account_number]) { is_expected.to eq('1') }
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('00000000000012811') }
62
+ its([:account_number]) { is_expected.to eq("1") }
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("00000000000012811") }
66
66
  end
67
67
 
68
- context 'from SEB' do
69
- let(:account_number) { '5439-10 240 39' }
68
+ context "from SEB" do
69
+ let(:account_number) { "5439-10 240 39" }
70
70
 
71
- its([:account_number]) { is_expected.to eq('1024039') }
72
- its([:branch_code]) { is_expected.to eq('5439') }
73
- its([:swift_bank_code]) { is_expected.to eq('500') }
74
- its([:swift_account_number]) { is_expected.to eq('00000054391024039') }
71
+ its([:account_number]) { is_expected.to eq("1024039") }
72
+ its([:branch_code]) { is_expected.to eq("5439") }
73
+ its([:swift_bank_code]) { is_expected.to eq("500") }
74
+ its([:swift_account_number]) { is_expected.to eq("00000054391024039") }
75
75
 
76
- context 'with a separate branch code' do
77
- let(:branch_code) { '5439' }
78
- let(:account_number) { '1024039' }
76
+ context "with a separate branch code" do
77
+ let(:branch_code) { "5439" }
78
+ let(:account_number) { "1024039" }
79
79
 
80
- its([:account_number]) { is_expected.to eq('1024039') }
81
- its([:branch_code]) { is_expected.to eq('5439') }
82
- its([:swift_bank_code]) { is_expected.to eq('500') }
80
+ its([:account_number]) { is_expected.to eq("1024039") }
81
+ its([:branch_code]) { is_expected.to eq("5439") }
82
+ its([:swift_bank_code]) { is_expected.to eq("500") }
83
83
  its([:swift_account_number]) do
84
- is_expected.to eq('00000054391024039')
84
+ is_expected.to eq("00000054391024039")
85
85
  end
86
86
  end
87
87
  end
88
88
  end
89
89
 
90
90
  context "with a clearing code that doesn't match any banks" do
91
- let(:account_number) { '1001-1' }
91
+ let(:account_number) { "1001-1" }
92
92
 
93
93
  its([:account_number]) { is_expected.to eq(nil) }
94
94
  its([:branch_code]) { is_expected.to eq(nil) }
95
95
  its([:swift_bank_code]) { is_expected.to eq(nil) }
96
- its([:swift_account_number]) { is_expected.to eq('00000000000010011') }
96
+ its([:swift_account_number]) { is_expected.to eq("00000000000010011") }
97
97
  end
98
98
 
99
- context 'with a Swedbank clearing code' do
100
- let(:account_number) { '7507-1211203' }
99
+ context "with a Swedbank clearing code" do
100
+ let(:account_number) { "7507-1211203" }
101
101
 
102
- its([:account_number]) { is_expected.to eq('1211203') }
103
- its([:branch_code]) { is_expected.to eq('7507') }
104
- its([:swift_bank_code]) { is_expected.to eq('800') }
105
- its([:swift_account_number]) { is_expected.to eq('00000075071211203') }
102
+ its([:account_number]) { is_expected.to eq("1211203") }
103
+ its([:branch_code]) { is_expected.to eq("7507") }
104
+ its([:swift_bank_code]) { is_expected.to eq("800") }
105
+ its([:swift_account_number]) { is_expected.to eq("00000075071211203") }
106
106
 
107
- context 'in the 8000s range' do
108
- let(:account_number) { '8327-9 33395390-9' }
107
+ context "in the 8000s range" do
108
+ let(:account_number) { "8327-9 33395390-9" }
109
109
 
110
- its([:account_number]) { is_expected.to eq('0333953909') }
111
- its([:branch_code]) { is_expected.to eq('83279') }
112
- its([:swift_bank_code]) { is_expected.to eq('800') }
113
- its([:swift_account_number]) { is_expected.to eq('00832790333953909') }
110
+ its([:account_number]) { is_expected.to eq("0333953909") }
111
+ its([:branch_code]) { is_expected.to eq("83279") }
112
+ its([:swift_bank_code]) { is_expected.to eq("800") }
113
+ its([:swift_account_number]) { is_expected.to eq("00832790333953909") }
114
114
  end
115
115
 
116
- context 'another in the 8000s range' do
117
- let(:account_number) { '8201-6 914357963-0' }
116
+ context "another in the 8000s range" do
117
+ let(:account_number) { "8201-6 914357963-0" }
118
118
 
119
- its([:account_number]) { is_expected.to eq('9143579630') }
120
- its([:branch_code]) { is_expected.to eq('82016') }
121
- its([:swift_bank_code]) { is_expected.to eq('800') }
122
- its([:swift_account_number]) { is_expected.to eq('00820169143579630') }
119
+ its([:account_number]) { is_expected.to eq("9143579630") }
120
+ its([:branch_code]) { is_expected.to eq("82016") }
121
+ its([:swift_bank_code]) { is_expected.to eq("800") }
122
+ its([:swift_account_number]) { is_expected.to eq("00820169143579630") }
123
123
  end
124
124
 
125
- context 'with an explicit branch code' do
126
- let(:branch_code) { '8201-6' }
127
- let(:account_number) { '914357963-0' }
125
+ context "with an explicit branch code" do
126
+ let(:branch_code) { "8201-6" }
127
+ let(:account_number) { "914357963-0" }
128
128
 
129
- its([:account_number]) { is_expected.to eq('9143579630') }
130
- its([:branch_code]) { is_expected.to eq('82016') }
131
- its([:swift_bank_code]) { is_expected.to eq('800') }
132
- its([:swift_account_number]) { is_expected.to eq('00820169143579630') }
129
+ its([:account_number]) { is_expected.to eq("9143579630") }
130
+ its([:branch_code]) { is_expected.to eq("82016") }
131
+ its([:swift_bank_code]) { is_expected.to eq("800") }
132
+ its([:swift_account_number]) { is_expected.to eq("00820169143579630") }
133
133
  end
134
134
 
135
- context 'in the 8000s range, with a very short input' do
136
- let(:account_number) { '8004' }
135
+ context "in the 8000s range, with a very short input" do
136
+ let(:account_number) { "8004" }
137
137
  let(:branch_code) { nil }
138
138
 
139
139
  its([:account_number]) { is_expected.to be_nil }
140
- its([:branch_code]) { is_expected.to eq('8004') }
141
- its([:swift_bank_code]) { is_expected.to eq('800') }
140
+ its([:branch_code]) { is_expected.to eq("8004") }
141
+ its([:swift_bank_code]) { is_expected.to eq("800") }
142
142
  its([:swift_account_number]) { is_expected.to be_nil }
143
143
  end
144
144
  end
145
145
 
146
- context 'with a Sparbanken Öresund clearing code' do
147
- let(:account_number) { '9300-35299478' }
146
+ context "with a Sparbanken Öresund clearing code" do
147
+ let(:account_number) { "9300-35299478" }
148
148
 
149
- its([:account_number]) { is_expected.to eq('35299478') }
150
- its([:branch_code]) { is_expected.to eq('9300') }
151
- its([:swift_bank_code]) { is_expected.to eq('930') }
152
- its([:swift_account_number]) { is_expected.to eq('00000000035299478') }
149
+ its([:account_number]) { is_expected.to eq("35299478") }
150
+ its([:branch_code]) { is_expected.to eq("9300") }
151
+ its([:swift_bank_code]) { is_expected.to eq("930") }
152
+ its([:swift_account_number]) { is_expected.to eq("00000000035299478") }
153
153
 
154
- context 'with clearing number 9330 or above' do
155
- let(:account_number) { '9330-5930160535' }
154
+ context "with clearing number 9330 or above" do
155
+ let(:account_number) { "9330-5930160535" }
156
156
 
157
- its([:account_number]) { is_expected.to eq('5930160535') }
158
- its([:branch_code]) { is_expected.to eq('9330') }
159
- its([:swift_bank_code]) { is_expected.to eq('933') }
160
- its([:swift_account_number]) { is_expected.to eq('00000005930160535') }
157
+ its([:account_number]) { is_expected.to eq("5930160535") }
158
+ its([:branch_code]) { is_expected.to eq("9330") }
159
+ its([:swift_bank_code]) { is_expected.to eq("933") }
160
+ its([:swift_account_number]) { is_expected.to eq("00000005930160535") }
161
161
  end
162
162
  end
163
163
 
164
- context 'with a Sparbanken Syd clearing code' do
165
- let(:account_number) { '9570-5250093407' }
164
+ context "with a Sparbanken Syd clearing code" do
165
+ let(:account_number) { "9570-5250093407" }
166
166
 
167
- its([:account_number]) { is_expected.to eq('5250093407') }
168
- its([:branch_code]) { is_expected.to eq('9570') }
169
- its([:swift_bank_code]) { is_expected.to eq('957') }
170
- its([:swift_account_number]) { is_expected.to eq('00000005250093407') }
167
+ its([:account_number]) { is_expected.to eq("5250093407") }
168
+ its([:branch_code]) { is_expected.to eq("9570") }
169
+ its([:swift_bank_code]) { is_expected.to eq("957") }
170
+ its([:swift_account_number]) { is_expected.to eq("00000005250093407") }
171
171
  end
172
172
 
173
- context 'with a Handelsbanken clearing code' do
174
- let(:account_number) { '6000-806967498' }
173
+ context "with a Handelsbanken clearing code" do
174
+ let(:account_number) { "6000-806967498" }
175
175
 
176
- its([:account_number]) { is_expected.to eq('806967498') }
177
- its([:branch_code]) { is_expected.to eq('6000') }
178
- its([:swift_bank_code]) { is_expected.to eq('600') }
179
- its([:swift_account_number]) { is_expected.to eq('00000000806967498') }
176
+ its([:account_number]) { is_expected.to eq("806967498") }
177
+ its([:branch_code]) { is_expected.to eq("6000") }
178
+ its([:swift_bank_code]) { is_expected.to eq("600") }
179
+ its([:swift_account_number]) { is_expected.to eq("00000000806967498") }
180
180
 
181
- context 'that has clearing code 6240' do
182
- let(:account_number) { '6240-219161038' }
181
+ context "that has clearing code 6240" do
182
+ let(:account_number) { "6240-219161038" }
183
183
 
184
- its([:account_number]) { is_expected.to eq('219161038') }
185
- its([:branch_code]) { is_expected.to eq('6240') }
186
- its([:swift_bank_code]) { is_expected.to eq('600') }
187
- its([:swift_account_number]) { is_expected.to eq('00000000219161038') }
184
+ its([:account_number]) { is_expected.to eq("219161038") }
185
+ its([:branch_code]) { is_expected.to eq("6240") }
186
+ its([:swift_bank_code]) { is_expected.to eq("600") }
187
+ its([:swift_account_number]) { is_expected.to eq("00000000219161038") }
188
188
  end
189
189
 
190
- context 'that only has an 8 digit serial number' do
191
- let(:account_number) { '6240-21916103' }
190
+ context "that only has an 8 digit serial number" do
191
+ let(:account_number) { "6240-21916103" }
192
192
 
193
- its([:account_number]) { is_expected.to eq('021916103') }
194
- its([:branch_code]) { is_expected.to eq('6240') }
195
- its([:swift_bank_code]) { is_expected.to eq('600') }
196
- its([:swift_account_number]) { is_expected.to eq('00000000021916103') }
193
+ its([:account_number]) { is_expected.to eq("021916103") }
194
+ its([:branch_code]) { is_expected.to eq("6240") }
195
+ its([:swift_bank_code]) { is_expected.to eq("600") }
196
+ its([:swift_account_number]) { is_expected.to eq("00000000021916103") }
197
197
  end
198
198
  end
199
199
 
200
- context 'with a Nordea PlusGirot clearing code' do
201
- let(:account_number) { '9960-3401258276' }
200
+ context "with a Nordea PlusGirot clearing code" do
201
+ let(:account_number) { "9960-3401258276" }
202
202
 
203
- its([:account_number]) { is_expected.to eq('3401258276') }
204
- its([:branch_code]) { is_expected.to eq('9960') }
205
- its([:swift_bank_code]) { is_expected.to eq('950') }
206
- its([:swift_account_number]) { is_expected.to eq('00099603401258276') }
203
+ its([:account_number]) { is_expected.to eq("3401258276") }
204
+ its([:branch_code]) { is_expected.to eq("9960") }
205
+ its([:swift_bank_code]) { is_expected.to eq("950") }
206
+ its([:swift_account_number]) { is_expected.to eq("00099603401258276") }
207
207
  end
208
208
  end
209
209
  end