portal_module 0.0.2

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.
Files changed (48) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +18 -0
  3. data/.rspec +3 -0
  4. data/Gemfile +13 -0
  5. data/Guardfile +24 -0
  6. data/LICENSE +22 -0
  7. data/LICENSE.txt +22 -0
  8. data/README.md +240 -0
  9. data/Rakefile +101 -0
  10. data/bin/portal_module +10 -0
  11. data/lib/portal_module/assertable.rb +37 -0
  12. data/lib/portal_module/cli.rb +35 -0
  13. data/lib/portal_module/client.rb +110 -0
  14. data/lib/portal_module/command/client_access.rb +41 -0
  15. data/lib/portal_module/command/config.rb +323 -0
  16. data/lib/portal_module/command/dts.rb +70 -0
  17. data/lib/portal_module/command/loan_entry.rb +66 -0
  18. data/lib/portal_module/command.rb +16 -0
  19. data/lib/portal_module/config_helper.rb +32 -0
  20. data/lib/portal_module/dts.rb +99 -0
  21. data/lib/portal_module/loan_entry.rb +101 -0
  22. data/lib/portal_module/page_factory.rb +27 -0
  23. data/lib/portal_module/pages/data_transformation_page.rb +84 -0
  24. data/lib/portal_module/pages/login_page.rb +73 -0
  25. data/lib/portal_module/pages/prequal_setup_page.rb +77 -0
  26. data/lib/portal_module/pages.rb +90 -0
  27. data/lib/portal_module/rake/dts_tasks.rb +166 -0
  28. data/lib/portal_module/rake/loan_entry_tasks.rb +166 -0
  29. data/lib/portal_module/rake.rb +16 -0
  30. data/lib/portal_module/version.rb +3 -0
  31. data/lib/portal_module.rb +251 -0
  32. data/portal_module.gemspec +33 -0
  33. data/spec/data/dts_import.xml +1 -0
  34. data/spec/data/le_import.xml +1 -0
  35. data/spec/lib/portal_module/cli_spec.rb +35 -0
  36. data/spec/lib/portal_module/client_spec.rb +126 -0
  37. data/spec/lib/portal_module/command/config_spec.rb +474 -0
  38. data/spec/lib/portal_module/command/dts_spec.rb +98 -0
  39. data/spec/lib/portal_module/command/loan_entry_spec.rb +98 -0
  40. data/spec/lib/portal_module/dts_spec.rb +145 -0
  41. data/spec/lib/portal_module/loan_entry_spec.rb +113 -0
  42. data/spec/lib/portal_module_spec.rb +175 -0
  43. data/spec/spec_helper.rb +52 -0
  44. data/spec/support/asserts.rb +10 -0
  45. data/spec/support/dirs.rb +53 -0
  46. data/spec/support/helpers.rb +44 -0
  47. data/spec/support/mocks.rb +106 -0
  48. metadata +247 -0
@@ -0,0 +1,474 @@
1
+ require 'pathname'
2
+ require Pathname(__FILE__).ascend{|d| h=d+'spec_helper.rb'; break h if h.file?}
3
+
4
+ describe 'config command' do
5
+
6
+ before do
7
+ # Reset config to a known state.
8
+ PortalModule.configuration.reset
9
+ # Delete any config file that may have been created.
10
+ file = Pathname.pwd + '.portal_module'
11
+ file.delete if file.exist?
12
+ end
13
+
14
+ let(:cli) { PortalModule::CLI }
15
+
16
+ it "returns help info" do
17
+ output = capture_output do
18
+ cli.start %w(help config)
19
+ end
20
+
21
+ expect( output ).to include "config help [COMMAND]"
22
+ expect( output ).to include "config add [CATEGORY]"
23
+ expect( output ).to include "config show [CATEGORY]"
24
+ expect( output ).to include "config del [CATEGORY]"
25
+ expect( output ).to include "config init"
26
+ expect( output ).to include "config timeout <seconds>"
27
+ expect( output ).to include "config defenv <envname>"
28
+ expect( output ).to include "config download_dir <dir>"
29
+ end
30
+
31
+ context 'config init' do
32
+
33
+ context "no filename/path provided" do
34
+ it "writes a configuration file to the current working directory" do
35
+ with_target_dir('config/init') do |working_dir|
36
+ output = capture_output do
37
+ run_with_args %w(config init)
38
+ end
39
+
40
+ output_file = Pathname(working_dir) + '.portal_module'
41
+
42
+ expect( output ).to include "configuration written to #{output_file.to_s}"
43
+ expect( output_file.exist? ).to eq true
44
+ end
45
+ end
46
+ end
47
+
48
+ context "filename/path provided" do
49
+ it "writes a configuration file to the specified directory" do
50
+ with_target_dir('config/init') do |working_dir|
51
+ final_dir = clean_target_dir(working_dir + 'nested/dir')
52
+
53
+ output = capture_output do
54
+ run_with_args %W(config init #{final_dir.to_s})
55
+ end
56
+
57
+ output_file = Pathname(final_dir) + '.portal_module'
58
+
59
+ expect( output_file.exist? ).to eq true
60
+ expect( output ).to include "configuration written to #{output_file.to_s}"
61
+ end
62
+ end
63
+ end
64
+ end
65
+
66
+ context 'config timeout' do
67
+
68
+ it "returns the current timeout when no argument provided" do
69
+ with_target_dir('config/timeout') do
70
+ run_with_args %w(config init -q)
71
+
72
+ output = capture_output do
73
+ run_with_args %w(config timeout)
74
+ end
75
+
76
+ expect( output ).to include 'browser timeout: 360'
77
+ end
78
+ end
79
+
80
+ it "sets the current timeout when an argument is provided" do
81
+ with_target_dir('config/timout') do
82
+ run_with_args %w(config init -q)
83
+
84
+ run_with_args %w(config timeout 180)
85
+
86
+ expect( PortalModule.configuration.browser_timeout ).to eq 180
87
+ end
88
+ end
89
+
90
+ it "displays an argument error if timeout value is not an integer" do
91
+ with_target_dir('config/timeout') do
92
+ output = capture_output do
93
+ run_with_args %w(config timeout blag)
94
+ end
95
+
96
+ expect( output ).to include 'argument error: seconds must be an integer'
97
+ end
98
+ end
99
+ end
100
+
101
+ context 'config defenv' do
102
+
103
+ it "returns the current default environment when no argument provided" do
104
+ with_target_dir('config/defenv') do
105
+ run_with_args %w(config init -q)
106
+
107
+ run_with_args %w(config add env test1 http://example.com)
108
+ run_with_args %w(config defenv test1)
109
+
110
+ output = capture_output do
111
+ run_with_args %w(config defenv)
112
+ end
113
+
114
+ expect( output ).to include 'default environment: test1'
115
+ end
116
+ end
117
+
118
+ it "sets the current default environment when an argument is provided" do
119
+ with_target_dir('config/defenv') do
120
+ run_with_args %w(config init -q)
121
+
122
+ run_with_args %w(config add env test2 http://example.com)
123
+ run_with_args %w(config defenv test2)
124
+
125
+ expect( PortalModule.configuration.default_environment ).to eq :test2
126
+ end
127
+ end
128
+
129
+ it "displays an argument error if environment doesn't exist" do
130
+ with_target_dir('config/defenv') do
131
+ run_with_args %w(config init -q)
132
+
133
+ output = capture_output do
134
+ run_with_args %w(config defenv nope)
135
+ end
136
+
137
+ expect( output ).to include "argument error: environment 'nope' has not been configured"
138
+ end
139
+ end
140
+ end
141
+
142
+ context 'config download_dir' do
143
+
144
+ it "returns the current download_dir when no argument provided" do
145
+ with_target_dir('config/download_dir') do
146
+ run_with_args %w(config init -q)
147
+
148
+ run_with_args %w(config download_dir test1)
149
+
150
+ output = capture_output do
151
+ run_with_args %w(config download_dir)
152
+ end
153
+
154
+ expect( output ).to include 'download dir: test1'
155
+ end
156
+ end
157
+
158
+ it "sets the current download_dir when an argument is provided" do
159
+ with_target_dir('config/download_dir') do
160
+ run_with_args %w(config init -q)
161
+
162
+ run_with_args %w(config download_dir test2)
163
+
164
+ expect( PortalModule.configuration.download_dir ).to eq 'test2'
165
+ end
166
+ end
167
+ end
168
+
169
+ context 'config add' do
170
+
171
+ it "returns help info" do
172
+ output = capture_output do
173
+ run_with_args %w(config help add)
174
+ end
175
+
176
+ expect( output ).to include "add help [COMMAND]"
177
+ expect( output ).to include "add env <envname> <url>"
178
+ expect( output ).to include "add org <orgname> <orgid>"
179
+ expect( output ).to include "add credentials <envname> <username> <pass>"
180
+ end
181
+
182
+ context "env" do
183
+
184
+ it "adds an environment" do
185
+ with_target_dir('config/add/env') do
186
+ run_with_args %w(config init -q)
187
+
188
+ run_with_args %w(config add env test http://example.com)
189
+
190
+ actual = PortalModule.configuration.base_urls[:test]
191
+ expect( actual ).to eq 'http://example.com'
192
+ end
193
+ end
194
+
195
+ it "displays an error if environment already exists" do
196
+ with_target_dir('config/add/env') do
197
+ run_with_args %w(config init -q)
198
+
199
+ run_with_args %w(config add env test http://example.com)
200
+
201
+ output = capture_output do
202
+ run_with_args %w(config add env test http://example.com)
203
+ end
204
+
205
+ expect( output ).to include "environment 'test' already exists"
206
+ end
207
+ end
208
+ end
209
+
210
+ context "org" do
211
+
212
+ it "adds an org unit and ID" do
213
+ with_target_dir('config/add/org') do
214
+ run_with_args %w(config init -q)
215
+
216
+ run_with_args ['config', 'add', 'org', 'Test Org', '1']
217
+
218
+ actual = PortalModule.configuration.orgs['Test Org']
219
+ expect( actual ).to eq '1'
220
+ end
221
+ end
222
+
223
+ it "displays an error if Org Unit already exists" do
224
+ org = 'Test Org'
225
+ with_target_dir('config/add/org') do
226
+ run_with_args %w(config init -q)
227
+
228
+ run_with_args ['config', 'add', 'org', org, '1']
229
+
230
+ output = capture_output do
231
+ run_with_args ['config', 'add', 'org', org, '1']
232
+ end
233
+
234
+ expect( output ).to include "org unit 'Test Org' already exists"
235
+ end
236
+ end
237
+ end
238
+
239
+ context "credentials" do
240
+
241
+ it "adds a set of credentials" do
242
+ with_target_dir('config/add/credentials') do
243
+ run_with_args %w(config init -q)
244
+
245
+ # Add an environment first...
246
+ run_with_args %w(config add env test http://example.com)
247
+
248
+ run_with_args %w(config add credentials test testuser testpass)
249
+
250
+ actual_user, actual_pass = PortalModule.configuration.credentials[:test]
251
+ expect( actual_user ).to eq 'testuser'
252
+ expect( actual_pass ).to eq 'testpass'
253
+ end
254
+ end
255
+
256
+ it "displays an error if credentials already exist for the given env" do
257
+ with_target_dir('config/add/credentials') do
258
+ run_with_args %w(config init -q)
259
+
260
+ # Add an environment first...
261
+ run_with_args %w(config add env test http://example.com)
262
+
263
+ run_with_args %w(config add credentials test testuser testpass)
264
+
265
+ output = capture_output do
266
+ run_with_args %w(config add credentials test testuser testpass)
267
+ end
268
+
269
+ expect( output ).to include "credentials already exist for environment 'test'"
270
+ end
271
+ end
272
+
273
+ it "displays an error if environment hasn't been created first" do
274
+ with_target_dir('config/add/credentials') do
275
+ run_with_args %w(config init -q)
276
+
277
+ output = capture_output do
278
+ run_with_args %w(config add credentials test testuser testpass)
279
+ end
280
+
281
+ expect( output ).to include "environment 'test' doesn't exist"
282
+ expect( output ).to include "create environment before adding credentials"
283
+ expect( PortalModule.configuration.credentials.key?(:test) ).to be false
284
+ end
285
+ end
286
+ end
287
+ end
288
+
289
+ context 'config show' do
290
+
291
+ it "returns help info" do
292
+ output = capture_output do
293
+ run_with_args %w(config help show)
294
+ end
295
+
296
+ expect( output ).to include "show help [COMMAND]"
297
+ expect( output ).to include "show envs"
298
+ expect( output ).to include "show orgs"
299
+ expect( output ).to include "show credentials <envname>"
300
+ end
301
+
302
+ context "orgs" do
303
+
304
+ it "displays configured Org Unis" do
305
+ with_target_dir('config/show/orgs') do
306
+ run_with_args %w(config init -q)
307
+
308
+ run_with_args %w(config add org test1 1)
309
+ run_with_args %w(config add org test2 2)
310
+
311
+ output = capture_output do
312
+ run_with_args %w(config show orgs)
313
+ end
314
+
315
+ expect( output ).to include 'Org Units:'
316
+ expect( output ).to include 'test1 1'
317
+ expect( output ).to include 'test2 2'
318
+ end
319
+ end
320
+ end
321
+
322
+ context "envs" do
323
+
324
+ it "displays configured environments" do
325
+ with_target_dir('config/show/environments') do
326
+ run_with_args %w(config init -q)
327
+
328
+ run_with_args %w(config add env test1 http://example.com)
329
+ run_with_args %w(config add env test2 http://example.org)
330
+
331
+ output = capture_output do
332
+ run_with_args %w(config show envs)
333
+ end
334
+
335
+ expect( output ).to include 'Environments:'
336
+ expect( output ).to include 'test1 http://example.com'
337
+ expect( output ).to include 'test2 http://example.org'
338
+ end
339
+ end
340
+ end
341
+
342
+ context "credentials" do
343
+
344
+ it "displays configured credentials" do
345
+ with_target_dir('config/show/credentials') do
346
+ run_with_args %w(config init -q)
347
+
348
+ run_with_args %w(config add env test1 http://example.com)
349
+ run_with_args %w(config add credentials test1 testuser1 testpass1)
350
+
351
+ run_with_args %w(config add env test2 http://example.org)
352
+ run_with_args %w(config add credentials test2 testuser2 testpass2)
353
+
354
+ output = capture_output do
355
+ run_with_args %w(config show credentials)
356
+ end
357
+
358
+ expect( output ).to include 'credentials:'
359
+ expect( output ).to include 'test1 testuser1 testpass1'
360
+ expect( output ).to include 'test2 testuser2 testpass2'
361
+ end
362
+ end
363
+
364
+ it "displays configured credentials for specified environment" do
365
+ with_target_dir('config/show/credentials') do
366
+ run_with_args %w(config init -q)
367
+
368
+ run_with_args %w(config add env test1 http://example.com)
369
+ run_with_args %w(config add credentials test1 testuser1 testpass1)
370
+
371
+ run_with_args %w(config add env test2 http://example.org)
372
+ run_with_args %w(config add credentials test2 testuser2 testpass2)
373
+
374
+ output = capture_output do
375
+ run_with_args %w(config show credentials test1)
376
+ end
377
+
378
+ expect( output ).to include 'credentials:'
379
+ expect( output ).to include 'test1 testuser1 testpass1'
380
+ expect( output ).to_not include 'test2 testuser2 testpass2'
381
+ end
382
+ end
383
+ end
384
+ end
385
+
386
+ context 'config del' do
387
+
388
+ it "returns help info" do
389
+ output = capture_output do
390
+ run_with_args %w(config help del)
391
+ end
392
+
393
+ expect( output ).to include "del help [COMMAND]"
394
+ expect( output ).to include "del env <envname>"
395
+ expect( output ).to include "del org <orgname>"
396
+ expect( output ).to include "del credentials <envname>"
397
+ end
398
+
399
+ context "env" do
400
+
401
+ it "deletes an existing environment" do
402
+ with_target_dir('config/del/env') do
403
+ run_with_args %w(config init -q)
404
+
405
+ run_with_args %w(config add env test1 http://example.com)
406
+
407
+ run_with_args %w(config del env test1)
408
+
409
+ expect( PortalModule.configuration.base_urls.key?(:test1) ).to be false
410
+ end
411
+ end
412
+
413
+ it "deletes matching credentials when deleting an environment" do
414
+ with_target_dir('config/del/env') do
415
+ run_with_args %w(config init -q)
416
+
417
+ run_with_args %w(config add env test1 http://example.com)
418
+ run_with_args %w(config add credentials test1 testuser1 testpass1)
419
+
420
+ run_with_args %w(config del env test1)
421
+
422
+ expect( PortalModule.configuration.base_urls.key?(:test1) ).to be false
423
+ expect( PortalModule.configuration.credentials.key?(:test1) ).to be false
424
+ end
425
+ end
426
+ end
427
+
428
+ context "org" do
429
+
430
+ it "deletes an existing Org Unit" do
431
+ with_target_dir('config/del/org') do
432
+ run_with_args %w(config init -q)
433
+
434
+ run_with_args %w(config add org test1 1)
435
+
436
+ run_with_args %w(config del org test1)
437
+
438
+ expect( PortalModule.configuration.orgs.key?('test1') ).to be false
439
+ end
440
+ end
441
+ end
442
+
443
+ context "credentials" do
444
+
445
+ it "deletes existing credentials" do
446
+ with_target_dir('config/del/credentials') do
447
+ run_with_args %w(config init -q)
448
+
449
+ run_with_args %w(config add env test1 http://example.com)
450
+ run_with_args %w(config add credentials test1 testuser1 testpass1)
451
+
452
+ run_with_args %w(config del credentials test1)
453
+
454
+ expect( PortalModule.configuration.credentials.key?(:test1) ).to be false
455
+ end
456
+ end
457
+
458
+ it "does not delete matching environment when deleting credentials" do
459
+ with_target_dir('config/del/credentials') do
460
+ run_with_args %w(config init -q)
461
+
462
+ run_with_args %w(config add env test1 http://example.com)
463
+ run_with_args %w(config add credentials test1 testuser1 testpass1)
464
+
465
+ run_with_args %w(config del credentials test1)
466
+
467
+ expect( PortalModule.configuration.base_urls.key?(:test1) ).to be true
468
+ expect( PortalModule.configuration.credentials.key?(:test1) ).to be false
469
+ end
470
+ end
471
+ end
472
+ end
473
+ end
474
+