yodlicious 0.0.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,469 @@
1
+ require "yodlicious"
2
+
3
+ describe 'the yodlee api client integration tests', integration: true do
4
+ let(:config) {
5
+ {
6
+ base_url: ENV['YODLEE_BASE_URL'],
7
+ cobranded_username: ENV['YODLEE_COBRANDED_USERNAME'],
8
+ cobranded_password: ENV['YODLEE_COBRANDED_PASSWORD'],
9
+ proxy_url: ENV['YODLICIOUS_PROXY_URL']
10
+ }
11
+ }
12
+
13
+ let(:api) { Yodlicious::YodleeApi.new(config) }
14
+
15
+ let(:registered_user) {
16
+ {
17
+ email: 'testuser_with_transactions@liftforward.com',
18
+ password: 'testpassword143'
19
+ }
20
+ }
21
+
22
+ describe 'the yodlee apis cobranded login endpoint' do
23
+ context 'Given valid cobranded credentials and base_url' do
24
+ context 'When /authenticate/coblogin is called the return' do
25
+ subject { api.cobranded_login }
26
+
27
+ it { is_expected.to be_kind_of(Yodlicious::Response) }
28
+ it { is_expected.to be_success }
29
+
30
+ it 'contains valid json response' do
31
+ expect(subject.body['cobrandConversationCredentials']).not_to be_nil
32
+ expect(subject.body['cobrandConversationCredentials']['sessionToken']).not_to be_nil
33
+ end
34
+ end
35
+ end
36
+ end
37
+
38
+ describe 'the yodlee apis user login endpoint' do
39
+ context 'Given valid cobranded credentials and base_url' do
40
+ context 'Given a new user who does not exist within the cobranded account' do
41
+ describe 'When /authenticate/coblogin is called the return' do
42
+ subject {
43
+ api.cobranded_login
44
+ api.user_login 'testuser', 'testpassword'
45
+ }
46
+
47
+ it { is_expected.to be_kind_of(Yodlicious::Response) }
48
+ it { is_expected.to be_fail }
49
+
50
+ it 'returns an error response' do
51
+ expect(subject.body).to eq({"Error"=>[{"errorDetail"=>"Invalid User Credentials"}]})
52
+ end
53
+ end
54
+ end
55
+
56
+ context 'Given a user who does exist within the cobranded account' do
57
+ describe 'When /authenticate/coblogin is called the return' do
58
+ subject {
59
+ api.cobranded_login
60
+ api.user_login 'testuser', 'testpassword'
61
+ }
62
+
63
+ it { is_expected.to be_kind_of(Yodlicious::Response) }
64
+ it { is_expected.to be_fail }
65
+
66
+ it 'returns an error response' do
67
+ expect(subject.body).to eq({"Error"=>[{"errorDetail"=>"Invalid User Credentials"}]})
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
73
+
74
+ describe 'the yodlee apis register user endpoint' do
75
+ context 'Given a valid cobranded credentials and base_url' do
76
+ context 'Given a new user who does not exist within the cobranded account' do
77
+ context 'When /jsonsdk/UserRegistration/register3 endpoint is called the response' do
78
+ subject {
79
+ api.cobranded_login
80
+ api.register_user "testuser#{rand(100...200)}", 'testpassword143', 'test@test.com'
81
+ }
82
+
83
+ after {
84
+ api.unregister_user
85
+ }
86
+
87
+ it 'is expected to offer a valid response' do
88
+ is_expected.to be_kind_of(Yodlicious::Response)
89
+ is_expected.to be_success
90
+ expect(subject.body['errorOccurred']).to be_nil
91
+ expect(subject.body['userContext']['conversationCredentials']['sessionToken']).to be_kind_of(String)
92
+ expect(subject.body['userContext']['conversationCredentials']['sessionToken'].length).to be > 0
93
+ expect(api.user_session_token).not_to be_nil
94
+ end
95
+ end
96
+ end
97
+ end
98
+ end
99
+
100
+ describe 'the yodlicious login_or_register_user method' do
101
+ before { api.cobranded_login }
102
+
103
+ context 'Given a new user with valid credentials' do
104
+ after { api.unregister_user }
105
+ let (:email) { "testuser#{rand(100...200)}@test.com" }
106
+ let (:password) { "password#{rand(100...200)}" }
107
+
108
+ context 'When login_or_register_user is called' do
109
+ subject { api.login_or_register_user email, password, email }
110
+
111
+ it 'should register the new user and set the user_session_token' do
112
+ expect(subject).to be_success
113
+ expect(subject).to be_kind_of(Yodlicious::Response)
114
+ expect(api.user_session_token).not_to be_nil
115
+ end
116
+ end
117
+ end
118
+
119
+ context 'Given an existing user with valid credentials' do
120
+ before { api.register_user registered_user[:email], registered_user[:password], registered_user[:email] }
121
+
122
+ context 'When login_or_register_user is called' do
123
+ subject { api.login_or_register_user registered_user[:email], registered_user[:password], registered_user[:email] }
124
+
125
+ it 'should login the user and not register them' do
126
+ expect(subject).to be_success
127
+ expect(subject).to be_kind_of(Yodlicious::Response)
128
+ expect(api.user_session_token).not_to be_nil
129
+ end
130
+ end
131
+ end
132
+ end
133
+
134
+ describe 'the yodlee apis site info endpoint' do
135
+ context 'Given a valid cobranded credentials and base_url' do
136
+ before {
137
+ api.cobranded_login
138
+ }
139
+
140
+ context 'When a request for site info is performed the result' do
141
+ subject { api.get_site_info 16441 }
142
+
143
+ it 'is expected to contain login form details' do
144
+ is_expected.not_to be_nil
145
+ is_expected.to be_kind_of(Yodlicious::Response)
146
+ expect(subject.body['errorOccurred']).to be_nil
147
+ expect(subject.body['loginForms']).not_to be_nil
148
+ expect(subject.body['loginForms']).to be_kind_of(Array)
149
+ expect(subject.body['loginForms'].length).to be > 0
150
+ end
151
+ end
152
+ end
153
+ end
154
+
155
+ #todo reorganize this spec to use given-when-then
156
+ describe 'Yodilicious add_site_account_and_wait method' do
157
+ context 'Given a user who has registered and does not have any accounts' do
158
+ before {
159
+ api.cobranded_login
160
+ # api.user_login 'testuser', 'testpassword143'
161
+ # api.unregister_user
162
+ # api.logout_user
163
+ api.register_user "testuser#{rand(100..999)}", 'testpassword143', 'test@test.com'
164
+ }
165
+
166
+ let(:seconds_between_retry) { 3 }
167
+ let(:retry_count) { 10 }
168
+
169
+ after {
170
+ begin
171
+ api.unregister_user
172
+ rescue
173
+ end
174
+ }
175
+
176
+ context 'When a invalid username and password for an account is added' do
177
+ before {
178
+ dag_login_form['componentList'][0]['value'] = 'invalid_username'
179
+ dag_login_form['componentList'][1]['value'] = 'invalid_password'
180
+ }
181
+ subject { api.add_site_account_and_wait(16441, dag_login_form, seconds_between_retry, retry_count) }
182
+
183
+ it 'is expected to respond with siteRefreshStatus=LOGIN_FAILURE and refreshMode=NORMAL a siteAccountId' do
184
+ # puts JSON.pretty_generate(subject.body)
185
+ is_expected.to be_success
186
+ expect(subject.body['siteRefreshInfo']['siteRefreshStatus']['siteRefreshStatus']).to eq('LOGIN_FAILURE')
187
+ expect(subject.body['siteRefreshInfo']['siteRefreshMode']['refreshMode']).to eq('NORMAL')
188
+ expect(subject.body['siteAccountId']).not_to be_nil
189
+ end
190
+ end
191
+
192
+ context 'When a valid username and password for an account is added' do
193
+ before {
194
+ dag_login_form['componentList'][0]['value'] = 'yodlicious.site16441.1'
195
+ dag_login_form['componentList'][1]['value'] = 'site16441.1'
196
+ }
197
+ subject { api.add_site_account_and_wait(16441, dag_login_form, seconds_between_retry, retry_count) }
198
+
199
+ it 'is expected to respond with siteRefreshStatus=LOGIN_SUCCESS and refreshMode=NORMAL a siteAccountId' do
200
+ is_expected.to be_success
201
+ expect(subject.body['siteRefreshInfo']['siteRefreshStatus']['siteRefreshStatus']).to eq('LOGIN_SUCCESS')
202
+ expect(subject.body['siteRefreshInfo']['siteRefreshMode']['refreshMode']).to eq('NORMAL')
203
+ expect(subject.body['siteAccountId']).not_to be_nil
204
+ end
205
+ end
206
+
207
+ end
208
+ end
209
+
210
+ describe 'the yodlee apis fetching summary data about registered site accounts endpoints' do
211
+ context 'Given a registered user with registered accounts' do
212
+ before {
213
+ api.cobranded_login
214
+ api.user_login "testuser_with_transactions@liftforward.com", 'testpassword143'
215
+ # api.register_user "testuser#{rand(100..999)}", 'testpassword143', 'test@test.com'
216
+ # dag_login_form[:componentList][0][:value] = 'yodlicious.site16441.1'
217
+ # dag_login_form[:componentList][1][:value] = 'site16441.1'
218
+ # api.add_site_account_and_wait(16441, dag_login_form)
219
+ }
220
+
221
+ # after {
222
+ # begin
223
+ # api.unregister_user
224
+ # rescue
225
+ # end
226
+ # }
227
+
228
+ context 'when getAllSiteAccounts is called the return' do
229
+ subject { api.get_all_site_accounts }
230
+
231
+ it 'is expected to return an array containing 1 siteAccount' do
232
+ # puts JSON.pretty_generate(subject)
233
+ is_expected.to be_success
234
+ expect(subject.body).to be_kind_of(Array)
235
+ expect(subject.body.length).to be > 0
236
+ expect(subject.body[0]['siteAccountId']).not_to be_nil
237
+ expect(subject.body[0]['siteRefreshInfo']['siteRefreshStatus']['siteRefreshStatus']).to eq('REFRESH_COMPLETED')
238
+
239
+ end
240
+ end
241
+
242
+ context 'when getItemSummariesForSite is called the return' do
243
+ subject {
244
+ site_accounts = api.get_all_site_accounts
245
+ # puts site_accounts[0]['siteAccountId']
246
+ # puts JSON.pretty_generate(site_accounts)
247
+ api.get_item_summaries_for_site(site_accounts.body[0]['siteAccountId'])
248
+ }
249
+
250
+ it 'is expected to return an array site summaries' do
251
+ # puts JSON.pretty_generate(subject)
252
+
253
+ is_expected.to be_kind_of(Yodlicious::Response)
254
+ is_expected.to be_success
255
+ expect(subject.body[0]['itemId']).not_to be_nil
256
+ end
257
+ end
258
+
259
+ context 'when getItemSummaries is called the return' do
260
+ subject { api.get_item_summaries }
261
+
262
+ it 'is expected to return an array of site summaries' do
263
+ # puts JSON.pretty_generate(subject)
264
+
265
+ is_expected.to be_kind_of(Yodlicious::Response)
266
+ is_expected.to be_success
267
+ expect(subject.body.length).to be > 0
268
+ expect(subject.body[0]['itemId']).not_to be_nil
269
+ end
270
+ end
271
+ end
272
+ end
273
+
274
+ describe 'the yodlee apis fetching user/s transactions' do
275
+ context 'Given a registered user with registered accounts' do
276
+ before {
277
+ api.cobranded_login
278
+ api.login_or_register_user 'testuser_with_transactions@liftforward.com', 'testpassword143', 'testuser_with_transactions@liftforward.com'
279
+ dag_login_form['componentList'][0]['value'] = 'yodlicious.site16441.1'
280
+ dag_login_form['componentList'][1]['value'] = 'site16441.1'
281
+ api.add_site_account_and_wait(16441, dag_login_form)
282
+ }
283
+
284
+ context 'When a transaction search for all transactions is performed the result' do
285
+ subject { api.execute_user_search_request }
286
+
287
+ it 'is expected to return a valid search result' do
288
+ # puts JSON.pretty_generate(subject.body)
289
+
290
+ is_expected.not_to be_nil
291
+ is_expected.to be_kind_of(Yodlicious::Response)
292
+ is_expected.to be_success
293
+ expect(subject.body['errorOccurred']).to be_nil
294
+ expect(subject.body['searchIdentifier']).not_to be_nil
295
+ expect(subject.body['searchResult']['transactions']).to be_kind_of(Array)
296
+ expect(subject.body['searchResult']['transactions'].length).to be > 0
297
+ end
298
+ end
299
+ end
300
+ end
301
+
302
+
303
+ # puts JSON.pretty_generate(subject)
304
+
305
+ # context 'downloading transaction history'
306
+
307
+ # context 'fetching a list of content services' do
308
+ # let (:api) { Yodlee::Base.new }
309
+ # before { api.login }
310
+
311
+ # subject { api.all_content_services }
312
+
313
+ # it 'returns a set of content services' do
314
+ # expect(subject).not_to be_empty
315
+ # end
316
+ # end
317
+
318
+
319
+ # context 'failing to create a new session' do
320
+ # it 'handles non 200 response gracefully'
321
+ # it 'handles 200 response with error message'
322
+ # end
323
+
324
+ # context 'failing when running a search for a site' do
325
+ # it 'return error json'
326
+ # end
327
+
328
+
329
+ # {
330
+ # "siteAccountId"=>10921402,
331
+ # "isCustom"=>false,
332
+ # "credentialsChangedTime"=>1424120024,
333
+ # "siteRefreshInfo"=>{
334
+ # "siteRefreshStatus"=>{
335
+ # "siteRefreshStatusId"=>1,
336
+ # "siteRefreshStatus"=>"REFRESH_TRIGGERED"
337
+ # },
338
+ # "siteRefreshMode"=>{
339
+ # "refreshModeId"=>2,
340
+ # "refreshMode"=>"NORMAL"
341
+ # },
342
+ # "updateInitTime"=>1424120024,
343
+ # "nextUpdate"=>1424120924,
344
+ # "code"=>801,
345
+ # "suggestedFlow"=>{
346
+ # "suggestedFlowId"=>2,
347
+ # "suggestedFlow"=>"REFRESH"
348
+ # },
349
+ # "noOfRetry"=>0
350
+ # },
351
+ # "siteInfo"=>{
352
+ # "popularity"=>0,
353
+ # "siteId"=>643,
354
+ # "orgId"=>520,
355
+ # "defaultDisplayName"=>"Chase",
356
+ # "defaultOrgDisplayName"=>"Chase Manhattan Bank",
357
+ # "enabledContainers"=>[
358
+ # {"containerName"=>"bank", "assetType"=>1},
359
+ # {"containerName"=>"bill_payment", "assetType"=>0},
360
+ # {"containerName"=>"credits", "assetType"=>2},
361
+ # {"containerName"=>"stocks", "assetType"=>1},
362
+ # {"containerName"=>"loans", "assetType"=>2},
363
+ # {"containerName"=>"mortgage", "assetType"=>2},
364
+ # {"containerName"=>"miles", "assetType"=>0}
365
+ # ],
366
+ # "baseUrl"=>"http://www.chase.com/",
367
+ # "loginForms"=>[],
368
+ # "isHeld"=>false,
369
+ # "isCustom"=>false,
370
+ # "siteSearchVisibility"=>true,
371
+ # "isAlreadyAddedByUser"=>true,
372
+ # "isOauthEnabled"=>false
373
+ # },
374
+ # "created"=>"2015-02-16T12:53:44-0800",
375
+ # "retryCount"=>0
376
+ # }
377
+
378
+
379
+ # {
380
+ # conjunctionOp: {
381
+ # conjuctionOp: 1
382
+ # },
383
+ # componentList: [
384
+ # {
385
+ # valueIdentifier: 'LOGIN',
386
+ # valueMask: 'LOGIN_FIELD',
387
+ # fieldType: {
388
+ # typeName: 'IF_LOGIN'
389
+ # },
390
+ # size: 20,
391
+ # maxlength: 32,
392
+ # name: 'LOGIN',
393
+ # displayName: 'User ID',
394
+ # isEditable: true,
395
+ # isOptional: false,
396
+ # isEscaped: false,
397
+ # helpText: 4710,
398
+ # isOptionalMFA: false,
399
+ # isMFA: false,
400
+ # value: 'yodlicious.site16441.1'
401
+ # },
402
+ # {
403
+ # valueIdentifier: 'PASSWORD',
404
+ # valueMask: 'LOGIN_FIELD',
405
+ # fieldType: {
406
+ # typeName: 'IF_PASSWORD'
407
+ # },
408
+ # size: 20,
409
+ # maxlength: 40,
410
+ # name: 'PASSWORD',
411
+ # displayName: 'Password',
412
+ # isEditable: true,
413
+ # isOptional: false,
414
+ # isEscaped: false,
415
+ # helpText: 11976,
416
+ # isOptionalMFA: false,
417
+ # isMFA: false,
418
+ # value: 'site16441.1'
419
+ # }
420
+ # ],
421
+ # defaultHelpText: 324
422
+ # }
423
+ # }
424
+
425
+ let(:dag_login_form) {
426
+ JSON.parse('{
427
+ "conjunctionOp": {
428
+ "conjuctionOp": 1
429
+ },
430
+ "componentList": [
431
+ {
432
+ "valueIdentifier": "LOGIN1",
433
+ "valueMask": "LOGIN_FIELD",
434
+ "fieldType": {
435
+ "typeName": "IF_LOGIN"
436
+ },
437
+ "size": 20,
438
+ "maxlength": 40,
439
+ "name": "LOGIN1",
440
+ "displayName": "Catalog",
441
+ "isEditable": true,
442
+ "isOptional": false,
443
+ "isEscaped": false,
444
+ "helpText": "150862",
445
+ "isOptionalMFA": false,
446
+ "isMFA": false
447
+ },
448
+ {
449
+ "valueIdentifier": "PASSWORD1",
450
+ "valueMask": "LOGIN_FIELD",
451
+ "fieldType": {
452
+ "typeName": "IF_PASSWORD"
453
+ },
454
+ "size": 20,
455
+ "maxlength": 40,
456
+ "name": "PASSWORD1",
457
+ "displayName": "Password",
458
+ "isEditable": true,
459
+ "isOptional": false,
460
+ "isEscaped": false,
461
+ "helpText": "150863",
462
+ "isOptionalMFA": false,
463
+ "isMFA": false
464
+ }
465
+ ],
466
+ "defaultHelpText": "16103"
467
+ }')
468
+ }
469
+ end
@@ -0,0 +1,13 @@
1
+ unless defined?(SPEC_HELPER_LOADED)
2
+ SPEC_HELPER_LOADED = true
3
+
4
+ require "yodlicious"
5
+
6
+
7
+ RSpec.configure do |config|
8
+
9
+ config.filter_run :focus
10
+ config.run_all_when_everything_filtered = true
11
+
12
+ end
13
+ end
@@ -0,0 +1,57 @@
1
+ require "spec_helper"
2
+ require "yodlicious/config"
3
+
4
+ describe Yodlicious::Config do
5
+ describe "#base_url" do
6
+ it "default value is nil" do
7
+ Yodlicious::Config.base_url = nil
8
+ end
9
+ end
10
+
11
+ describe "#cobranded_username" do
12
+ it "default value is nil" do
13
+ Yodlicious::Config.cobranded_username = nil
14
+ end
15
+ end
16
+
17
+ describe "#cobranded_password" do
18
+ it "default value is nil" do
19
+ Yodlicious::Config.cobranded_password = nil
20
+ end
21
+ end
22
+
23
+ describe "#proxy_url" do
24
+ it "default value is nil" do
25
+ Yodlicious::Config.proxy_url = nil
26
+ end
27
+ end
28
+
29
+ describe "#base_url=" do
30
+ it "can set value" do
31
+ Yodlicious::Config.base_url = 'http://someurl'
32
+ expect(Yodlicious::Config.base_url).to eq('http://someurl')
33
+ end
34
+ end
35
+
36
+ describe "#cobranded_username=" do
37
+ it "can set value" do
38
+ Yodlicious::Config.cobranded_username = 'some username'
39
+ expect(Yodlicious::Config.cobranded_username).to eq('some username')
40
+ end
41
+ end
42
+
43
+ describe "#cobranded_password=" do
44
+ it "can set value" do
45
+ Yodlicious::Config.cobranded_password = 'some password'
46
+ expect(Yodlicious::Config.cobranded_password).to eq('some password')
47
+ end
48
+ end
49
+
50
+ describe "#proxy_url=" do
51
+ it "can set value" do
52
+ Yodlicious::Config.proxy_url = 'http://someurl'
53
+ expect(Yodlicious::Config.proxy_url).to eq('http://someurl')
54
+ end
55
+ end
56
+
57
+ end
@@ -0,0 +1,80 @@
1
+ require "yodlicious/parameter_translator"
2
+
3
+ describe 'parameter translator' do
4
+ subject { Yodlicious::ParameterTranslator.new }
5
+ context 'converting login params json to add site params' do
6
+ let (:login_form) {
7
+ {
8
+ 'componentList' => [
9
+ {
10
+ 'valueIdentifier' => 'LOGIN',
11
+ 'valueMask' => 'LOGIN_FIELD',
12
+ 'fieldType' => {
13
+ 'typeName' => 'IF_LOGIN'
14
+ },
15
+ 'size' => 20,
16
+ 'maxlength' => 32,
17
+ 'name' => 'LOGIN',
18
+ 'displayName' => 'User ID',
19
+ 'isEditable' => true,
20
+ 'isOptional' => false,
21
+ 'isEscaped' => false,
22
+ 'helpText' => 4710,
23
+ 'isOptionalMFA' => false,
24
+ 'isMFA' => false,
25
+ 'value' => 'kanyewest'
26
+ },
27
+ {
28
+ 'valueIdentifier' => 'PASSWORD',
29
+ 'valueMask' => 'LOGIN_FIELD',
30
+ 'fieldType' => {
31
+ 'typeName' => 'IF_PASSWORD'
32
+ },
33
+ 'size' => 20,
34
+ 'maxlength' => 40,
35
+ 'name' => 'PASSWORD',
36
+ 'displayName' => 'Password',
37
+ 'isEditable' => true,
38
+ 'isOptional' => false,
39
+ 'isEscaped' => false,
40
+ 'helpText' => 11976,
41
+ 'isOptionalMFA' => false,
42
+ 'isMFA' => false,
43
+ 'value' => 'iLoveTheGrammys'
44
+ }
45
+ ]
46
+ }
47
+ }
48
+
49
+ let (:add_site_params) {
50
+ {
51
+ "credentialFields.enclosedType" => "com.yodlee.common.FieldInfoSingle",
52
+ "credentialFields[0].displayName" => "User ID",
53
+ "credentialFields[0].fieldType.typeName" => "IF_LOGIN",
54
+ "credentialFields[0].helpText" => 4710,
55
+ "credentialFields[0].maxlength" => 32,
56
+ "credentialFields[0].name" => "LOGIN",
57
+ "credentialFields[0].size" => 20,
58
+ "credentialFields[0].value" => 'kanyewest',
59
+ "credentialFields[0].valueIdentifier" => "LOGIN",
60
+ "credentialFields[0].valueMask" => "LOGIN_FIELD",
61
+ "credentialFields[0].isEditable" => true,
62
+ "credentialFields[1].displayName" => "Password",
63
+ "credentialFields[1].fieldType.typeName" => "IF_PASSWORD",
64
+ "credentialFields[1].helpText" => 11976,
65
+ "credentialFields[1].maxlength" => 40,
66
+ "credentialFields[1].name" => "PASSWORD",
67
+ "credentialFields[1].size" => 20,
68
+ "credentialFields[1].value" => 'iLoveTheGrammys',
69
+ "credentialFields[1].valueIdentifier" => "PASSWORD",
70
+ "credentialFields[1].valueMask" => "LOGIN_FIELD",
71
+ "credentialFields[1].isEditable" => true
72
+ }
73
+ }
74
+
75
+ it "converts correctly to params hash" do
76
+ expect(subject.site_login_form_to_add_site_account_params(login_form)).to be == add_site_params
77
+ end
78
+
79
+ end
80
+ end
@@ -0,0 +1,61 @@
1
+ require "yodlicious"
2
+
3
+ describe Yodlicious::Response do
4
+ let(:error_response_1) {
5
+ {
6
+ "errorOccurred"=>"true",
7
+ "exceptionType"=>"com.yodlee.core.IllegalArgumentValueException",
8
+ "referenceCode"=>"_3932d208-345a-400f-a273-83619b8b548b",
9
+ "message"=>"Multiple exceptions encapsulated within: invoke getWrappedExceptions for details"
10
+ }
11
+ }
12
+
13
+ let(:error_response_2) {
14
+ { "Error" => [ {"errorDetail" => "Invalid User Credentials"} ] }
15
+ }
16
+
17
+ let(:success_hash_response) {
18
+ {}
19
+ }
20
+
21
+ let(:success_array_response) {
22
+ [{}]
23
+ }
24
+
25
+ context 'When the error_response is the errorOccured syntax' do
26
+ subject { Yodlicious::Response.new error_response_1 }
27
+ it { is_expected.not_to be_success }
28
+ it { is_expected.to be_fail }
29
+ it "is expected to return error of InvalidArgumentValueException" do
30
+ expect(subject.error).to eq('com.yodlee.core.IllegalArgumentValueException')
31
+ end
32
+ end
33
+
34
+ context 'When the error_response is the Error : ["errorDetail"] syntax' do
35
+ subject { Yodlicious::Response.new error_response_2 }
36
+ it { is_expected.not_to be_success }
37
+ it { is_expected.to be_fail }
38
+ it "is expected to return error of Invalid User Credentials" do
39
+ expect(subject.error).to eq('Invalid User Credentials')
40
+ end
41
+ end
42
+
43
+ context 'When operation is a success and returns hash' do
44
+ subject { Yodlicious::Response.new success_hash_response }
45
+ it { is_expected.to be_success }
46
+ it { is_expected.not_to be_fail }
47
+ it 'is expected to return nil for error' do
48
+ expect(subject.error).to be_nil
49
+ end
50
+ end
51
+
52
+ context 'When operation is a success and return array' do
53
+ subject { Yodlicious::Response.new success_array_response }
54
+ it { is_expected.to be_success }
55
+ it { is_expected.not_to be_fail }
56
+ it 'is expected to return nil for error' do
57
+ expect(subject.error).to be_nil
58
+ end
59
+ end
60
+
61
+ end