esortcode 0.9.1

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.
@@ -0,0 +1,13 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ describe ESortCode::Client, "when not instanciated" do
4
+ it "should allow set of account name" do
5
+ ESortCode::Client.account_name = "testing@example.com"
6
+ ESortCode::Client.account_name.should eql('testing@example.com')
7
+ end
8
+
9
+ it "should allow set of guid" do
10
+ ESortCode::Client.guid = "3823148732r8ewurwyeurcbewyuvywe"
11
+ ESortCode::Client.guid.should eql('3823148732r8ewurwyeurcbewyuvywe')
12
+ end
13
+ end
@@ -0,0 +1,9 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ describe ESortCode do
4
+ it "should have a client constant" do
5
+ lambda {
6
+ ESortCode::Client
7
+ }.should_not raise_error(NameError)
8
+ end
9
+ end
@@ -0,0 +1,324 @@
1
+ require File.dirname(__FILE__) + '/common_spec.rb'
2
+
3
+ module ResponseBranchDetailsSpecHelper
4
+ def valid_response
5
+ <<-EOF
6
+ <?xml version="1.0" encoding="utf-8"?>
7
+ <BranchDetail xmlns="https://ws.esortcode.com">
8
+ <ValidationMessage>VALID</ValidationMessage>
9
+ <IsError>false</IsError>
10
+ <ErrorMessage/>
11
+ <GENERALSortingCode>404031</GENERALSortingCode>
12
+ <GENERALBIC1/>
13
+ <GENERALBIC2/>
14
+ <GENERALSubBranchSuffix/>
15
+ <GENERALShortBranchTitle/>
16
+ <GENERALShortNameOwningBank/>
17
+ <GENERALFullNameOwningBankLine1/>
18
+ <GENERALFullNameOwningBankLine2/>
19
+ <GENERALBankCodeOwningBank/>
20
+ <GENERALNationalCentralBankCountryCode/>
21
+ <GENERALSupervisoryBody/>
22
+ <GENERALDeletedDate/>
23
+ <GENERALDateofLastChange/>
24
+ <GENERALPrintIndicator/>
25
+ <BACSStatus/>
26
+ <BACSDateofLastChange/>
27
+ <BACSDateClosedInBACSClearing/>
28
+ <BACSRedirectionFromFlag/>
29
+ <BACSRedirectToSortcode/>
30
+ <BACSSettlementBank/>
31
+ <BACSSettlementSection/>
32
+ <BACSSettlementSubSection/>
33
+ <BACSHandlingBank/>
34
+ <BACSHandlingBankStream/>
35
+ <BACSAccountsNumberedFlag/>
36
+ <BACSDDIVoucherFlag/>
37
+ <BACSTransactionsDisallowedDR/>
38
+ <BACSTransactionsDisallowedCR/>
39
+ <BACSTransactionsDisallowedCU/>
40
+ <BACSTransactionsDisallowedPR/>
41
+ <BACSTransactionsDisallowedBS/>
42
+ <BACSTransactionsDisallowedDV/>
43
+ <BACSTransactionsDisallowedAU/>
44
+ <BACSTransactionsDisallowedSpare1/>
45
+ <BACSTransactionsDisallowedSpare2/>
46
+ <BACSTransactionsDisallowedSpare3/>
47
+ <BACSSpare1/>
48
+ <CHAPSSTERLINGReturnIndicator/>
49
+ <CHAPSSTERLINGStatus/>
50
+ <CHAPSSTERLINGEffectiveDateOfLastChange/>
51
+ <CHAPSSTERLINGDateClosed/>
52
+ <CHAPSSTERLINGSettlementMember/>
53
+ <CHAPSSTERLINGRoutingBICField1/>
54
+ <CHAPSSTERLINGRoutingBICField2/>
55
+ <CHAPSEUROStatus/>
56
+ <CHAPSEUROEffectiveDateOfLastChange/>
57
+ <CHAPSEURODateClosed/>
58
+ <CHAPSEURORoutingBICField1/>
59
+ <CHAPSEURORoutingBICField2/>
60
+ <CHAPSEUROSettlementMember/>
61
+ <CHAPSEUROReturnIndicator/>
62
+ <CHAPSEUROSwiftData/>
63
+ <CHAPSEUROSpare1/>
64
+ <CCCCStatus/>
65
+ <CCCCeffectiveDateofLastChange/>
66
+ <CCCCDateClosed/>
67
+ <CCCCSettlementBank/>
68
+ <CCCCDebitAgencySortingCode/>
69
+ <CCCCReturnIndicator/>
70
+ <CCCCGBNIIndicator/>
71
+ <PRINTBranchTypeIndicator/>
72
+ <PRINTSortcodeOfMainBranch/>
73
+ <PRINTMajorLocationName/>
74
+ <PRINTMinorLocationName/>
75
+ <PRINTBranchNameOrPlace/>
76
+ <PRINTSecondEntryIndicator/>
77
+ <PRINTBranchNameForSecondEntry/>
78
+ <PRINTFullBranchTitlePart1/>
79
+ <PRINTFullBranchTitlePart2/>
80
+ <PRINTFullBranchTitlePart3/>
81
+ <PRINTAddressLine1/>
82
+ <PRINTAddressLine2/>
83
+ <PRINTAddressLine3/>
84
+ <PRINTAddressLine4/>
85
+ <PRINTTown/>
86
+ <PRINTCounty/>
87
+ <PRINTPostcodeField1/>
88
+ <PRINTPostcodeField2/>
89
+ <PRINTTelephoneArea/>
90
+ <PRINTTelephoneNumber/>
91
+ <PRINTTelephone2Area/>
92
+ <PRINTTelephone2Number/>
93
+ </BranchDetail>
94
+ EOF
95
+ end
96
+
97
+ def invalid_response
98
+ <<-EOF
99
+ <?xml version="1.0" encoding="utf-8"?>
100
+ <BranchDetail xmlns="https://ws.esortcode.com">
101
+ <ValidationMessage>INVALID: "Chunky Bacon"</ValidationMessage>
102
+ <IsError>false</IsError>
103
+ <ErrorMessage/>
104
+ <GENERALSortingCode/>
105
+ <GENERALBIC1/>
106
+ <GENERALBIC2/>
107
+ <GENERALSubBranchSuffix/>
108
+ <GENERALShortBranchTitle/>
109
+ <GENERALShortNameOwningBank/>
110
+ <GENERALFullNameOwningBankLine1/>
111
+ <GENERALFullNameOwningBankLine2/>
112
+ <GENERALBankCodeOwningBank/>
113
+ <GENERALNationalCentralBankCountryCode/>
114
+ <GENERALSupervisoryBody/>
115
+ <GENERALDeletedDate/>
116
+ <GENERALDateofLastChange/>
117
+ <GENERALPrintIndicator/>
118
+ <BACSStatus/>
119
+ <BACSDateofLastChange/>
120
+ <BACSDateClosedInBACSClearing/>
121
+ <BACSRedirectionFromFlag/>
122
+ <BACSRedirectToSortcode/>
123
+ <BACSSettlementBank/>
124
+ <BACSSettlementSection/>
125
+ <BACSSettlementSubSection/>
126
+ <BACSHandlingBank/>
127
+ <BACSHandlingBankStream/>
128
+ <BACSAccountsNumberedFlag/>
129
+ <BACSDDIVoucherFlag/>
130
+ <BACSTransactionsDisallowedDR/>
131
+ <BACSTransactionsDisallowedCR/>
132
+ <BACSTransactionsDisallowedCU/>
133
+ <BACSTransactionsDisallowedPR/>
134
+ <BACSTransactionsDisallowedBS/>
135
+ <BACSTransactionsDisallowedDV/>
136
+ <BACSTransactionsDisallowedAU/>
137
+ <BACSTransactionsDisallowedSpare1/>
138
+ <BACSTransactionsDisallowedSpare2/>
139
+ <BACSTransactionsDisallowedSpare3/>
140
+ <BACSSpare1/>
141
+ <CHAPSSTERLINGReturnIndicator/>
142
+ <CHAPSSTERLINGStatus/>
143
+ <CHAPSSTERLINGEffectiveDateOfLastChange/>
144
+ <CHAPSSTERLINGDateClosed/>
145
+ <CHAPSSTERLINGSettlementMember/>
146
+ <CHAPSSTERLINGRoutingBICField1/>
147
+ <CHAPSSTERLINGRoutingBICField2/>
148
+ <CHAPSEUROStatus/>
149
+ <CHAPSEUROEffectiveDateOfLastChange/>
150
+ <CHAPSEURODateClosed/>
151
+ <CHAPSEURORoutingBICField1/>
152
+ <CHAPSEURORoutingBICField2/>
153
+ <CHAPSEUROSettlementMember/>
154
+ <CHAPSEUROReturnIndicator/>
155
+ <CHAPSEUROSwiftData/>
156
+ <CHAPSEUROSpare1/>
157
+ <CCCCStatus/>
158
+ <CCCCeffectiveDateofLastChange/>
159
+ <CCCCDateClosed/>
160
+ <CCCCSettlementBank/>
161
+ <CCCCDebitAgencySortingCode/>
162
+ <CCCCReturnIndicator/>
163
+ <CCCCGBNIIndicator/>
164
+ <PRINTBranchTypeIndicator/>
165
+ <PRINTSortcodeOfMainBranch/>
166
+ <PRINTMajorLocationName/>
167
+ <PRINTMinorLocationName/>
168
+ <PRINTBranchNameOrPlace/>
169
+ <PRINTSecondEntryIndicator/>
170
+ <PRINTBranchNameForSecondEntry/>
171
+ <PRINTFullBranchTitlePart1/>
172
+ <PRINTFullBranchTitlePart2/>
173
+ <PRINTFullBranchTitlePart3/>
174
+ <PRINTAddressLine1/>
175
+ <PRINTAddressLine2/>
176
+ <PRINTAddressLine3/>
177
+ <PRINTAddressLine4/>
178
+ <PRINTTown/>
179
+ <PRINTCounty/>
180
+ <PRINTPostcodeField1/>
181
+ <PRINTPostcodeField2/>
182
+ <PRINTTelephoneArea/>
183
+ <PRINTTelephoneNumber/>
184
+ <PRINTTelephone2Area/>
185
+ <PRINTTelephone2Number/>
186
+ </BranchDetail>
187
+ EOF
188
+ end
189
+
190
+ def error_response
191
+ <<-EOF
192
+ <?xml version="1.0" encoding="utf-8"?>
193
+ <BranchDetail xmlns="https://ws.esortcode.com">
194
+ <ValidationMessage/>
195
+ <IsError>true</IsError>
196
+ <ErrorMessage>ERROR: "No Chunky Bacon"</ErrorMessage>
197
+ <GENERALSortingCode/>
198
+ <GENERALBIC1/>
199
+ <GENERALBIC2/>
200
+ <GENERALSubBranchSuffix/>
201
+ <GENERALShortBranchTitle/>
202
+ <GENERALShortNameOwningBank/>
203
+ <GENERALFullNameOwningBankLine1/>
204
+ <GENERALFullNameOwningBankLine2/>
205
+ <GENERALBankCodeOwningBank/>
206
+ <GENERALNationalCentralBankCountryCode/>
207
+ <GENERALSupervisoryBody/>
208
+ <GENERALDeletedDate/>
209
+ <GENERALDateofLastChange/>
210
+ <GENERALPrintIndicator/>
211
+ <BACSStatus/>
212
+ <BACSDateofLastChange/>
213
+ <BACSDateClosedInBACSClearing/>
214
+ <BACSRedirectionFromFlag/>
215
+ <BACSRedirectToSortcode/>
216
+ <BACSSettlementBank/>
217
+ <BACSSettlementSection/>
218
+ <BACSSettlementSubSection/>
219
+ <BACSHandlingBank/>
220
+ <BACSHandlingBankStream/>
221
+ <BACSAccountsNumberedFlag/>
222
+ <BACSDDIVoucherFlag/>
223
+ <BACSTransactionsDisallowedDR/>
224
+ <BACSTransactionsDisallowedCR/>
225
+ <BACSTransactionsDisallowedCU/>
226
+ <BACSTransactionsDisallowedPR/>
227
+ <BACSTransactionsDisallowedBS/>
228
+ <BACSTransactionsDisallowedDV/>
229
+ <BACSTransactionsDisallowedAU/>
230
+ <BACSTransactionsDisallowedSpare1/>
231
+ <BACSTransactionsDisallowedSpare2/>
232
+ <BACSTransactionsDisallowedSpare3/>
233
+ <BACSSpare1/>
234
+ <CHAPSSTERLINGReturnIndicator/>
235
+ <CHAPSSTERLINGStatus/>
236
+ <CHAPSSTERLINGEffectiveDateOfLastChange/>
237
+ <CHAPSSTERLINGDateClosed/>
238
+ <CHAPSSTERLINGSettlementMember/>
239
+ <CHAPSSTERLINGRoutingBICField1/>
240
+ <CHAPSSTERLINGRoutingBICField2/>
241
+ <CHAPSEUROStatus/>
242
+ <CHAPSEUROEffectiveDateOfLastChange/>
243
+ <CHAPSEURODateClosed/>
244
+ <CHAPSEURORoutingBICField1/>
245
+ <CHAPSEURORoutingBICField2/>
246
+ <CHAPSEUROSettlementMember/>
247
+ <CHAPSEUROReturnIndicator/>
248
+ <CHAPSEUROSwiftData/>
249
+ <CHAPSEUROSpare1/>
250
+ <CCCCStatus/>
251
+ <CCCCeffectiveDateofLastChange/>
252
+ <CCCCDateClosed/>
253
+ <CCCCSettlementBank/>
254
+ <CCCCDebitAgencySortingCode/>
255
+ <CCCCReturnIndicator/>
256
+ <CCCCGBNIIndicator/>
257
+ <PRINTBranchTypeIndicator/>
258
+ <PRINTSortcodeOfMainBranch/>
259
+ <PRINTMajorLocationName/>
260
+ <PRINTMinorLocationName/>
261
+ <PRINTBranchNameOrPlace/>
262
+ <PRINTSecondEntryIndicator/>
263
+ <PRINTBranchNameForSecondEntry/>
264
+ <PRINTFullBranchTitlePart1/>
265
+ <PRINTFullBranchTitlePart2/>
266
+ <PRINTFullBranchTitlePart3/>
267
+ <PRINTAddressLine1/>
268
+ <PRINTAddressLine2/>
269
+ <PRINTAddressLine3/>
270
+ <PRINTAddressLine4/>
271
+ <PRINTTown/>
272
+ <PRINTCounty/>
273
+ <PRINTPostcodeField1/>
274
+ <PRINTPostcodeField2/>
275
+ <PRINTTelephoneArea/>
276
+ <PRINTTelephoneNumber/>
277
+ <PRINTTelephone2Area/>
278
+ <PRINTTelephone2Number/>
279
+ </BranchDetail>
280
+ EOF
281
+ end
282
+ end
283
+
284
+ describe ESortCode::Response::BranchDetails, "when given valid response" do
285
+ include ResponseBranchDetailsSpecHelper
286
+
287
+ before do
288
+ @response = ESortCode::Response::BranchDetails.new(valid_response)
289
+ end
290
+
291
+ it_should_behave_like 'All Valid Responses'
292
+
293
+ it "should return 404031 for GENERALSortingCode" do
294
+ @response.directory['GENERALSortingCode'].should eql('404031')
295
+ end
296
+ end
297
+
298
+ describe ESortCode::Response::BranchDetails, "when given invalid response" do
299
+ include ResponseBranchDetailsSpecHelper
300
+
301
+ before do
302
+ @response = ESortCode::Response::BranchDetails.new(invalid_response)
303
+ end
304
+
305
+ it_should_behave_like 'All Invalid Responses'
306
+
307
+ it "should not have GENERALSortingCode" do
308
+ @response.directory['GENERALSortingCode'].should be_nil
309
+ end
310
+ end
311
+
312
+ describe ESortCode::Response::BranchDetails, "when given error response" do
313
+ include ResponseBranchDetailsSpecHelper
314
+
315
+ before do
316
+ @response = ESortCode::Response::BranchDetails.new(error_response)
317
+ end
318
+
319
+ it_should_behave_like 'All Error Responses'
320
+
321
+ it "should not have GENERALSortingCode" do
322
+ @response.directory['GENERALSortingCode'].should be_nil
323
+ end
324
+ end
@@ -0,0 +1,57 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper.rb'
2
+ require File.dirname(__FILE__) + '/../../lib/esortcode.rb'
3
+ require File.dirname(__FILE__) + '/../../lib/esortcode/response.rb'
4
+
5
+ describe "All Valid Responses", :shared => true do
6
+ it "should be valid" do
7
+ @response.should be_valid
8
+ end
9
+
10
+ it "should not have an invalid_message" do
11
+ @response.invalid_message.should be_nil
12
+ end
13
+
14
+ it "should not have an error" do
15
+ @response.should_not have_error
16
+ end
17
+
18
+ it "should not have an error string" do
19
+ @response.error.should be_nil
20
+ end
21
+ end
22
+
23
+ describe "All Invalid Responses", :shared => true do
24
+ it "should not be valid" do
25
+ @response.should_not be_valid
26
+ end
27
+
28
+ it "should have an invalid_message" do
29
+ @response.invalid_message.should eql("Chunky Bacon")
30
+ end
31
+
32
+ it "should not have an error" do
33
+ @response.should_not have_error
34
+ end
35
+
36
+ it "should not have an error string" do
37
+ @response.error.should be_nil
38
+ end
39
+ end
40
+
41
+ describe "All Error Responses", :shared => true do
42
+ it "should not be valid" do
43
+ @response.should_not be_valid
44
+ end
45
+
46
+ it "should not have an invalid_message" do
47
+ @response.invalid_message.should be_nil
48
+ end
49
+
50
+ it "should have an error" do
51
+ @response.should have_error
52
+ end
53
+
54
+ it "should have an error string" do
55
+ @response.error.should eql("No Chunky Bacon")
56
+ end
57
+ end
@@ -0,0 +1,96 @@
1
+ require File.dirname(__FILE__) + '/common_spec.rb'
2
+
3
+ module ResponseStandardiseAccountSpecHelper
4
+ def valid_response
5
+ <<-EOF
6
+ <?xml version="1.0" encoding="utf-8"?>
7
+ <Standardise xmlns="https://ws.esortcode.com">
8
+ <ValidationMessage>VALID</ValidationMessage>
9
+ <IsError>false</IsError>
10
+ <ErrorMessage/>
11
+ <StandardisedSortcode>404031</StandardisedSortcode>
12
+ <StandardisedAccountNumber>58762916</StandardisedAccountNumber>
13
+ </Standardise>
14
+ EOF
15
+ end
16
+
17
+ def invalid_response
18
+ <<-EOF
19
+ <?xml version="1.0" encoding="utf-8"?>
20
+ <Standardise xmlns="https://ws.esortcode.com">
21
+ <ValidationMessage>INVALID: "Chunky Bacon"</ValidationMessage>
22
+ <IsError>false</IsError>
23
+ <ErrorMessage/>
24
+ <StandardisedSortcode/>
25
+ <StandardisedAccountNumber/>
26
+ </Standardise>
27
+ EOF
28
+ end
29
+
30
+ def error_response
31
+ <<-EOF
32
+ <?xml version="1.0" encoding="utf-8"?>
33
+ <Standardise xmlns="https://ws.esortcode.com">
34
+ <ValidationMessage/>
35
+ <IsError>true</IsError>
36
+ <ErrorMessage>ERROR: "No Chunky Bacon"</ErrorMessage>
37
+ <StandardisedSortcode/>
38
+ <StandardisedAccountNumber/>
39
+ </Standardise>
40
+ EOF
41
+ end
42
+ end
43
+
44
+ describe ESortCode::Response::StandardiseAccount, "when given valid response" do
45
+ include ResponseStandardiseAccountSpecHelper
46
+
47
+ before do
48
+ @response = ESortCode::Response::StandardiseAccount.new(valid_response)
49
+ end
50
+
51
+ it_should_behave_like 'All Valid Responses'
52
+
53
+ it "should have standardised sort code" do
54
+ @response.sort_code.should eql('404031')
55
+ end
56
+
57
+ it "should have standardised account number" do
58
+ @response.account_number.should eql('58762916')
59
+ end
60
+ end
61
+
62
+ describe ESortCode::Response::StandardiseAccount, "when given invalid response" do
63
+ include ResponseStandardiseAccountSpecHelper
64
+
65
+ before do
66
+ @response = ESortCode::Response::StandardiseAccount.new(invalid_response)
67
+ end
68
+
69
+ it_should_behave_like 'All Invalid Responses'
70
+
71
+ it "should not have standardised sort code" do
72
+ @response.sort_code.should be_nil
73
+ end
74
+
75
+ it "should not have standardised account number" do
76
+ @response.account_number.should be_nil
77
+ end
78
+ end
79
+
80
+ describe ESortCode::Response::StandardiseAccount, "when given error response" do
81
+ include ResponseStandardiseAccountSpecHelper
82
+
83
+ before do
84
+ @response = ESortCode::Response::StandardiseAccount.new(error_response)
85
+ end
86
+
87
+ it_should_behave_like 'All Error Responses'
88
+
89
+ it "should not have standardised sort code" do
90
+ @response.sort_code.should be_nil
91
+ end
92
+
93
+ it "should not have standardised account number" do
94
+ @response.account_number.should be_nil
95
+ end
96
+ end