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