cukesparse 2.0.4 → 2.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,53 @@
1
+ require 'helper'
2
+
3
+ describe '.set_cucumber_defaults' do
4
+ before :each do
5
+ ARGV.clear
6
+ Cukesparse.reset!
7
+ end
8
+
9
+ context "when run with no cucumber_defaults defined" do
10
+ it "will return a warning" do
11
+ ARGV.push('no_defaults')
12
+ Cukesparse.configure {|c| c.config_file = File.join(fixture_path, 'valid_tasks.yml')}
13
+ Cukesparse.load_config
14
+ Cukesparse.check_for_task
15
+ Cukesparse.should_receive("puts").with("\e[0;33;49mWARN: The task has no cucumber defaults!\e[0m")
16
+ Cukesparse.set_cucumber_defaults
17
+ end
18
+ end
19
+
20
+ context "when run with no arguments passed" do
21
+ before do
22
+ ARGV.push('test_task', '-t', 'test')
23
+ Cukesparse.parameters = {}
24
+ Cukesparse.configure {|c| c.config_file = File.join(fixture_path, 'valid_tasks.yml')}
25
+ Cukesparse.load_config.parse_argv
26
+ Cukesparse.check_for_task
27
+ Cukesparse.check_for_parameters
28
+ Cukesparse.set_cucumber_defaults
29
+ end
30
+
31
+ it "will have cucumber default parameters" do
32
+ Cukesparse.parameters.should have_key :format
33
+ Cukesparse.parameters.should have_key :name
34
+ Cukesparse.parameters.should have_key :tags
35
+ Cukesparse.parameters.should have_key :strict
36
+ Cukesparse.parameters.should have_key :verbose
37
+ Cukesparse.parameters.should have_key :dry_run
38
+ Cukesparse.parameters.should have_key :guess
39
+ Cukesparse.parameters.should have_key :expand
40
+ end
41
+
42
+ it "will have the expected default runtime parameter values" do
43
+ Cukesparse.parameters[:format].should eql '--format pretty'
44
+ Cukesparse.parameters[:name].should eql ['--name feature1', '--name feature2']
45
+ Cukesparse.parameters[:tags].should eql ['--tags test', '--tags tags1', '--tags tags2']
46
+ Cukesparse.parameters[:strict].should eql '--strict'
47
+ Cukesparse.parameters[:verbose].should eql '--verbose'
48
+ Cukesparse.parameters[:dry_run].should eql '--dry-run'
49
+ Cukesparse.parameters[:guess].should eql '--guess'
50
+ Cukesparse.parameters[:expand].should eql '--expand'
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,62 @@
1
+ require 'helper'
2
+
3
+ describe '.set_runtime_defaults' do
4
+ before :each do
5
+ ARGV.clear
6
+ Cukesparse.reset!
7
+ end
8
+
9
+ context "when run with no runtime_defaults defined" do
10
+ it "will return a warning if no runtime_defaults are provided" do
11
+ ARGV.push('no_defaults')
12
+ Cukesparse.configure {|c| c.config_file = File.join(fixture_path, 'valid_tasks.yml')}
13
+ Cukesparse.load_config
14
+ Cukesparse.check_for_task
15
+ Cukesparse.should_receive("puts").with("\e[0;33;49mWARN: The task has no runtime defaults!\e[0m")
16
+ Cukesparse.set_runtime_defaults
17
+ end
18
+ end
19
+
20
+ context "when run" do
21
+ before do
22
+ ARGV.push('test_task', '-t', 'test')
23
+ Cukesparse.parameters = {}
24
+ Cukesparse.configure {|c| c.config_file = File.join(fixture_path, 'valid_tasks.yml')}
25
+ Cukesparse.load_config.parse_argv
26
+ Cukesparse.check_for_task
27
+ Cukesparse.check_for_parameters
28
+ Cukesparse.set_runtime_defaults
29
+ end
30
+
31
+ it "will have runtime default parameters" do
32
+ Cukesparse.parameters.should have_key :environment
33
+ Cukesparse.parameters.should have_key :log_level
34
+ Cukesparse.parameters.should have_key :cleanup
35
+ Cukesparse.parameters.should have_key :database
36
+ Cukesparse.parameters.should have_key :jenkins
37
+ Cukesparse.parameters.should have_key :retries
38
+ Cukesparse.parameters.should have_key :timeout
39
+ Cukesparse.parameters.should have_key :screenwidth
40
+ Cukesparse.parameters.should have_key :screenheight
41
+ Cukesparse.parameters.should have_key :xposition
42
+ Cukesparse.parameters.should have_key :yposition
43
+ Cukesparse.parameters.should have_key :highlight
44
+ end
45
+
46
+ it "will have the expected default runtime parameter values" do
47
+ Cukesparse.parameters[:environment].should eql 'ENVIRONMENT=release'
48
+ Cukesparse.parameters[:log_level].should eql 'LOG_LEVEL=debug'
49
+ Cukesparse.parameters[:cleanup].should eql 'CLEANUP=true'
50
+ Cukesparse.parameters[:database].should eql 'DATABASE=true'
51
+ Cukesparse.parameters[:jenkins].should eql 'JENKINS=true'
52
+ Cukesparse.parameters[:retries].should eql 'RETRIES=5'
53
+ Cukesparse.parameters[:timeout].should eql 'TIMEOUT=60'
54
+ Cukesparse.parameters[:screenwidth].should eql 'SCREENWIDTH=1280'
55
+ Cukesparse.parameters[:screenheight].should eql 'SCREENHEIGHT=1024'
56
+ Cukesparse.parameters[:xposition].should eql 'XPOSITION=0'
57
+ Cukesparse.parameters[:yposition].should eql 'YPOSITION=0'
58
+ Cukesparse.parameters[:highlight].should eql 'HIGHLIGHT=true'
59
+ end
60
+ end
61
+
62
+ end
@@ -0,0 +1,42 @@
1
+ require 'helper'
2
+
3
+ describe '.split_parameters' do
4
+ before :each do
5
+ ARGV.clear
6
+ Cukesparse.reset!
7
+ end
8
+
9
+ context "when run with arguments and :screen symbol" do
10
+ it "will return set a parameters screen key and value" do
11
+ Cukesparse.split_parameters('1024/1280', :screen)
12
+ Cukesparse.parameters.should have_key(:screenwidth)
13
+ Cukesparse.parameters.should have_key(:screenheight)
14
+ Cukesparse.parameters[:screenwidth].should eql "SCREENWIDTH=1024"
15
+ Cukesparse.parameters[:screenheight].should eql "SCREENHEIGHT=1280"
16
+ end
17
+ end
18
+
19
+ context "when run with arguments and :position symbol" do
20
+ it "will return set a parameters screen key and value" do
21
+ Cukesparse.split_parameters('0/100', :position)
22
+ Cukesparse.parameters.should have_key(:xposition)
23
+ Cukesparse.parameters.should have_key(:yposition)
24
+ Cukesparse.parameters[:xposition].should eql "XPOSITION=0"
25
+ Cukesparse.parameters[:yposition].should eql "YPOSITION=100"
26
+ end
27
+ end
28
+
29
+ context "when run with one argument" do
30
+ it "will return a you have passed enough parameters error" do
31
+ Cukesparse.should_receive("abort").with("\e[4;31;49mERROR: You have not passed enough parameters in the test command line argument!\e[0m")
32
+ Cukesparse.split_parameters('1024', :test)
33
+ end
34
+ end
35
+
36
+ context "when run with over two argument" do
37
+ it "will return a you have passed to many parameters error" do
38
+ Cukesparse.should_receive("abort").with("\e[4;31;49mERROR: You have passed to many parameters in the test command line argument!\e[0m")
39
+ Cukesparse.split_parameters('1024/1280/16', :test)
40
+ end
41
+ end
42
+ end
@@ -1,17 +1,12 @@
1
- require 'coveralls'
2
- Coveralls.wear!
3
-
4
- require 'cukesparse'
5
- require 'rspec'
1
+ require 'helper'
6
2
 
7
3
  describe "cukesparse" do
8
-
9
4
  before :each do
10
5
  ARGV.clear
6
+ Cukesparse.reset!
11
7
  end
12
8
 
13
- # Object
14
- context "when called" do
9
+ context "when run" do
15
10
  it "should be an instance of Module" do
16
11
  Cukesparse.should be_an_instance_of Module
17
12
  end
@@ -32,916 +27,4 @@ describe "cukesparse" do
32
27
  Cukesparse.command.should be_empty
33
28
  end
34
29
  end
35
-
36
- context "when called with no argument" do
37
- it "should display a cukesparse information message" do
38
- Cukesparse.should_receive("puts").with("\e[0;33;49mCukesparse - a simple command line parser to pass arguments into Cucumber!\e[0m")
39
- Cukesparse.execute
40
- end
41
- end
42
-
43
- context "when called with the task argument" do
44
- it "should display the tasks within the config file" do
45
- ARGV.push('tasks')
46
- Cukesparse.should_receive("puts").with("\e[0;33;49mYou have the following tasks within your config file: test_task\e[0m")
47
- Cukesparse.execute
48
- end
49
- end
50
-
51
- # Parameters
52
- context "when passed the -t parameter" do
53
- before :all do
54
- # Clear arguments as rspec passes in script path
55
- ARGV.push('test_task', '-t', 'test')
56
- Cukesparse.parameters = {}
57
- Cukesparse.parse_argv
58
- end
59
-
60
- it "should have a parameter of tags" do
61
- Cukesparse.parameters.should have_key :tags
62
- end
63
-
64
- it "should have a tags parameter value of --tags test" do
65
- Cukesparse.parameters[:tags].should eql ['--tags test']
66
- end
67
- end
68
-
69
- context "when passed the -n parameter" do
70
- before :all do
71
- # Clear arguments as rspec passes in script path
72
- ARGV.push('test_task', '-n', 'name_test')
73
- Cukesparse.parameters = {}
74
- Cukesparse.parse_argv
75
- end
76
-
77
- it "should have a parameter of name" do
78
- Cukesparse.parameters.should have_key :name
79
- end
80
-
81
- it "should have a name parameter value of test" do
82
- Cukesparse.parameters[:name].should eql ['--name name_test']
83
- end
84
- end
85
-
86
- context "when passed the -name parameter" do
87
- before :all do
88
- # Clear arguments as rspec passes in script path
89
- ARGV.push('test_task', '--name', 'name_test')
90
- Cukesparse.parameters = {}
91
- Cukesparse.parse_argv
92
- end
93
-
94
- it "should have a parameter of name" do
95
- Cukesparse.parameters.should have_key :name
96
- end
97
-
98
- it "should have a name parameter value of test" do
99
- Cukesparse.parameters[:name].should eql ['--name name_test']
100
- end
101
- end
102
-
103
- context "when passed the -f parameter" do
104
- before :all do
105
- # Clear arguments as rspec passes in script path
106
- ARGV.push('test_task', '-f', 'pretty')
107
- Cukesparse.parameters = {}
108
- Cukesparse.parse_argv
109
- end
110
-
111
- it "should have a parameter of format" do
112
- Cukesparse.parameters.should have_key :format
113
- end
114
-
115
- it "should have a tags parameter value of test" do
116
- Cukesparse.parameters[:format].should eql '--format pretty'
117
- end
118
- end
119
-
120
- context "when passed the --format parameter" do
121
- before :all do
122
- # Clear arguments as rspec passes in script path
123
- ARGV.push('test_task', '--format', 'pretty')
124
- Cukesparse.parameters = {}
125
- Cukesparse.parse_argv
126
- end
127
-
128
- it "should have a parameter of format" do
129
- Cukesparse.parameters.should have_key :format
130
- end
131
-
132
- it "should have a tags parameter value of test" do
133
- Cukesparse.parameters[:format].should eql '--format pretty'
134
- end
135
- end
136
-
137
- context "when passed the -d parameter" do
138
- before :all do
139
- # Clear arguments as rspec passes in script path
140
- ARGV.push('test_task', '-d')
141
- Cukesparse.parameters = {}
142
- Cukesparse.parse_argv
143
- end
144
-
145
- it "should have a parameter of name" do
146
- Cukesparse.parameters.should have_key :dry_run
147
- end
148
-
149
- it "should have a dry_run parameter value of --dry-run" do
150
- Cukesparse.parameters[:dry_run].should eql '--dry-run'
151
- end
152
- end
153
-
154
- context "when passed the --dry-run parameter" do
155
- before :all do
156
- # Clear arguments as rspec passes in script path
157
- ARGV.push('test_task', '--dry-run')
158
- Cukesparse.parameters = {}
159
- Cukesparse.parse_argv
160
- end
161
-
162
- it "should have a parameter of dry_run" do
163
- Cukesparse.parameters.should have_key :dry_run
164
- end
165
-
166
- it "should have a dry_run parameter value of --dry-run" do
167
- Cukesparse.parameters[:dry_run].should eql '--dry-run'
168
- end
169
- end
170
-
171
- context "when passed the -v parameter" do
172
- before :all do
173
- # Clear arguments as rspec passes in script path
174
- ARGV.push('test_task', '-v')
175
- Cukesparse.parameters = {}
176
- Cukesparse.parse_argv
177
- end
178
-
179
- it "should have a parameter of verbose" do
180
- Cukesparse.parameters.should have_key :verbose
181
- end
182
-
183
- it "should have a verbose parameter value of --verbose" do
184
- Cukesparse.parameters[:verbose].should eql '--verbose'
185
- end
186
- end
187
-
188
- context "when passed the --verbose parameter" do
189
- before :all do
190
- # Clear arguments as rspec passes in script path
191
- ARGV.push('test_task', '--verbose')
192
- Cukesparse.parameters = {}
193
- Cukesparse.parse_argv
194
- end
195
-
196
- it "should have a parameter of verbose" do
197
- Cukesparse.parameters.should have_key :verbose
198
- end
199
-
200
- it "should have a verbose parameter value of --verbose" do
201
- Cukesparse.parameters[:verbose].should eql '--verbose'
202
- end
203
- end
204
-
205
- context "when passed the -s parameter" do
206
- before :all do
207
- # Clear arguments as rspec passes in script path
208
- ARGV.push('test_task', '-s')
209
- Cukesparse.parameters = {}
210
- Cukesparse.parse_argv
211
- end
212
-
213
- it "should have a parameter of strict" do
214
- Cukesparse.parameters.should have_key :strict
215
- end
216
-
217
- it "should have a strict parameter value of --strict" do
218
- Cukesparse.parameters[:strict].should eql '--strict'
219
- end
220
- end
221
-
222
- context "when passed the --strict parameter" do
223
- before :all do
224
- # Clear arguments as rspec passes in script path
225
- ARGV.push('test_task', '-s')
226
- Cukesparse.parameters = {}
227
- Cukesparse.parse_argv
228
- end
229
-
230
- it "should have a parameter of --strict" do
231
- Cukesparse.parameters.should have_key :strict
232
- end
233
-
234
- it "should have a strict parameter value of --strict" do
235
- Cukesparse.parameters[:strict].should eql '--strict'
236
- end
237
- end
238
-
239
- context "when passed the -g parameter" do
240
- before :all do
241
- # Clear arguments as rspec passes in script path
242
- ARGV.push('test_task', '-g')
243
- Cukesparse.parameters = {}
244
- Cukesparse.parse_argv
245
- end
246
-
247
- it "should have a parameter of --guess" do
248
- Cukesparse.parameters.should have_key :guess
249
- end
250
-
251
- it "should have a strict parameter value of --guess" do
252
- Cukesparse.parameters[:guess].should eql '--guess'
253
- end
254
- end
255
-
256
- context "when passed the --guess parameter" do
257
- before :all do
258
- # Clear arguments as rspec passes in script path
259
- ARGV.push('test_task', '--guess')
260
- Cukesparse.parameters = {}
261
- Cukesparse.parse_argv
262
- end
263
-
264
- it "should have a parameter of --guess" do
265
- Cukesparse.parameters.should have_key :guess
266
- end
267
-
268
- it "should have a strict parameter value of --guess" do
269
- Cukesparse.parameters[:guess].should eql '--guess'
270
- end
271
- end
272
-
273
- context "when passed the -x parameter" do
274
- before :all do
275
- # Clear arguments as rspec passes in script path
276
- ARGV.push('test_task', '-x')
277
- Cukesparse.parameters = {}
278
- Cukesparse.parse_argv
279
- end
280
-
281
- it "should have a parameter of --expand" do
282
- Cukesparse.parameters.should have_key :expand
283
- end
284
-
285
- it "should have a strict parameter value of --expand" do
286
- Cukesparse.parameters[:expand].should eql '--expand'
287
- end
288
- end
289
-
290
- context "when passed the --expand parameter" do
291
- before :all do
292
- # Clear arguments as rspec passes in script path
293
- ARGV.push('test_task', '--expand')
294
- Cukesparse.parameters = {}
295
- Cukesparse.parse_argv
296
- end
297
-
298
- it "should have a parameter of --expand" do
299
- Cukesparse.parameters.should have_key :expand
300
- end
301
-
302
- it "should have a strict parameter value of --expand" do
303
- Cukesparse.parameters[:expand].should eql '--expand'
304
- end
305
- end
306
-
307
- context "when passed the -e parameter" do
308
- before :all do
309
- # Clear arguments as rspec passes in script path
310
- ARGV.push('test_task', '-e', 'test_environment')
311
- Cukesparse.parameters = {}
312
- Cukesparse.parse_argv
313
- end
314
-
315
- it "should have a parameter of environment" do
316
- Cukesparse.parameters.should have_key :environment
317
- end
318
-
319
- it "should have a environment parameter value of ENVIRONMENT=test_environment" do
320
- Cukesparse.parameters[:environment].should eql 'ENVIRONMENT=test_environment'
321
- end
322
- end
323
-
324
- context "when passed the --environment parameter" do
325
- before :all do
326
- # Clear arguments as rspec passes in script path
327
- ARGV.push('test_task', '--environment', 'test_environment')
328
- Cukesparse.parameters = {}
329
- Cukesparse.parse_argv
330
- end
331
-
332
- it "should have a parameter of environment" do
333
- Cukesparse.parameters.should have_key :environment
334
- end
335
-
336
- it "should have a environment parameter value of ENVIRONMENT=test_environment" do
337
- Cukesparse.parameters[:environment].should eql 'ENVIRONMENT=test_environment'
338
- end
339
- end
340
-
341
- context "when passed the -l parameter" do
342
- before :all do
343
- # Clear arguments as rspec passes in script path
344
- ARGV.push('test_task', '-l', 'debug')
345
- Cukesparse.parameters = {}
346
- Cukesparse.parse_argv
347
- end
348
-
349
- it "should have a parameter of loglevel" do
350
- Cukesparse.parameters.should have_key :log_level
351
- end
352
-
353
- it "should have a loglevel parameter value of LOG_LEVEL=debug" do
354
- Cukesparse.parameters[:log_level].should eql 'LOG_LEVEL=debug'
355
- end
356
- end
357
-
358
- context "when passed the --loglevel parameter" do
359
- before :all do
360
- # Clear arguments as rspec passes in script path
361
- ARGV.push('test_task', '--loglevel', 'debug')
362
- Cukesparse.parameters = {}
363
- Cukesparse.parse_argv
364
- end
365
-
366
- it "should have a parameter of loglevel" do
367
- Cukesparse.parameters.should have_key :log_level
368
- end
369
-
370
- it "should have a loglevel parameter value of LOG_LEVEL=debug" do
371
- Cukesparse.parameters[:log_level].should eql 'LOG_LEVEL=debug'
372
- end
373
- end
374
-
375
- context "when passed the -c parameter" do
376
- before :all do
377
- # Clear arguments as rspec passes in script path
378
- ARGV.push('test_task', '-c', 'browser')
379
- Cukesparse.parameters = {}
380
- Cukesparse.parse_argv
381
- end
382
-
383
- it "should have a parameter of controller" do
384
- Cukesparse.parameters.should have_key :controller
385
- end
386
-
387
- it "should have a controller parameter value of CONTROLLER=browser" do
388
- Cukesparse.parameters[:controller].should eql 'CONTROLLER=browser'
389
- end
390
- end
391
-
392
- context "when passed the --controller parameter" do
393
- before :all do
394
- # Clear arguments as rspec passes in script path
395
- ARGV.push('test_task', '--controller', 'browser')
396
- Cukesparse.parameters = {}
397
- Cukesparse.parse_argv
398
- end
399
-
400
- it "should have a parameter of controller" do
401
- Cukesparse.parameters.should have_key :controller
402
- end
403
-
404
- it "should have a controller parameter value of CONTROLLER=browser" do
405
- Cukesparse.parameters[:controller].should eql 'CONTROLLER=browser'
406
- end
407
- end
408
-
409
- context "when passed the -h parameter" do
410
- before :all do
411
- # Clear arguments as rspec passes in script path
412
- ARGV.push('test_task', '-h')
413
- Cukesparse.parameters = {}
414
- Cukesparse.parse_argv
415
- end
416
-
417
- it "should have a parameter of headless" do
418
- Cukesparse.parameters.should have_key :headless
419
- end
420
-
421
- it "should have a headless parameter value of HEADLESS=TRUE" do
422
- Cukesparse.parameters[:headless].should eql 'HEADLESS=TRUE'
423
- end
424
- end
425
-
426
- context "when passed the --headless parameter" do
427
- before :all do
428
- # Clear arguments as rspec passes in script path
429
- ARGV.push('test_task', '--headless')
430
- Cukesparse.parameters = {}
431
- Cukesparse.parse_argv
432
- end
433
-
434
- it "should have a parameter of headless" do
435
- Cukesparse.parameters.should have_key :headless
436
- end
437
-
438
- it "should have a headless parameter value of HEADLESS=TRUE" do
439
- Cukesparse.parameters[:headless].should eql 'HEADLESS=TRUE'
440
- end
441
- end
442
-
443
- context "when passed the --cleanup parameter" do
444
- before :all do
445
- # Clear arguments as rspec passes in script path
446
- ARGV.push('test_task', '--cleanup')
447
- Cukesparse.parameters = {}
448
- Cukesparse.parse_argv
449
- end
450
-
451
- it "should have a parameter of cleanup" do
452
- Cukesparse.parameters.should have_key :cleanup
453
- end
454
-
455
- it "should have a cleanup parameter value of CLEANUP=TRUE" do
456
- Cukesparse.parameters[:cleanup].should eql 'CLEANUP=TRUE'
457
- end
458
- end
459
-
460
- context "when passed the --no-cleanup parameter" do
461
- before :all do
462
- # Clear arguments as rspec passes in script path
463
- ARGV.push('test_task', '--no-cleanup')
464
- Cukesparse.parameters = {}
465
- Cukesparse.parse_argv
466
- end
467
-
468
- it "should have a parameter of cleanup" do
469
- Cukesparse.parameters.should have_key :cleanup
470
- end
471
-
472
- it "should have a cleanup parameter value of CLEANUP=FALSE" do
473
- Cukesparse.parameters[:cleanup].should eql 'CLEANUP=FALSE'
474
- end
475
- end
476
-
477
- context "when passed the --database parameter" do
478
- before :all do
479
- # Clear arguments as rspec passes in script path
480
- ARGV.push('test_task', '--database')
481
- Cukesparse.parameters = {}
482
- Cukesparse.parse_argv
483
- end
484
-
485
- it "should have a parameter of database" do
486
- Cukesparse.parameters.should have_key :database
487
- end
488
-
489
- it "should have a database parameter value of DATABASE=TRUE" do
490
- Cukesparse.parameters[:database].should eql 'DATABASE=TRUE'
491
- end
492
- end
493
-
494
- context "when passed the --jenkins parameter" do
495
- before :all do
496
- # Clear arguments as rspec passes in script path
497
- ARGV.push('test_task', '--jenkins')
498
- Cukesparse.parameters = {}
499
- Cukesparse.parse_argv
500
- end
501
-
502
- it "should have a parameter of jenkins" do
503
- Cukesparse.parameters.should have_key :jenkins
504
- end
505
-
506
- it "should have a jenkins parameter value of JENKINS=TRUE" do
507
- Cukesparse.parameters[:jenkins].should eql 'JENKINS=TRUE'
508
- end
509
- end
510
-
511
- context "when passed the --retries parameter" do
512
- before :all do
513
- # Clear arguments as rspec passes in script path
514
- ARGV.push('test_task', '--retries', '5')
515
- Cukesparse.parameters = {}
516
- Cukesparse.parse_argv
517
- end
518
-
519
- it "should have a parameter of retries" do
520
- Cukesparse.parameters.should have_key :retries
521
- end
522
-
523
- it "should have a retries parameter value of RETRIES=5" do
524
- Cukesparse.parameters[:retries].should eql 'RETRIES=5'
525
- end
526
- end
527
-
528
- context "when passed the --timeout parameter" do
529
- before :all do
530
- # Clear arguments as rspec passes in script path
531
- ARGV.push('test_task', '--timeout', '10')
532
- Cukesparse.parameters = {}
533
- Cukesparse.parse_argv
534
- end
535
-
536
- it "should have a parameter of timeout" do
537
- Cukesparse.parameters.should have_key :timeout
538
- end
539
-
540
- it "should have a timeout parameter value of TIMEOUT=10" do
541
- Cukesparse.parameters[:timeout].should eql 'TIMEOUT=10'
542
- end
543
- end
544
-
545
- context "when passed the --screen parameter" do
546
- before :all do
547
- # Clear arguments as rspec passes in script path
548
- ARGV.push('test_task', '--screen', '1280/1024')
549
- Cukesparse.parameters = {}
550
- Cukesparse.parse_argv
551
- end
552
-
553
- it "should have a parameter of screenwidth" do
554
- Cukesparse.parameters.should have_key :screenwidth
555
- end
556
-
557
- it "should have a parameter of screenheight" do
558
- Cukesparse.parameters.should have_key :screenheight
559
- end
560
-
561
- it "should have a screenwidth parameter value of SCREENWIDTH=1280" do
562
- Cukesparse.parameters[:screenwidth].should eql 'SCREENWIDTH=1280'
563
- end
564
-
565
- it "should have a screenheight parameter value of SCREENHEIGHT=1024" do
566
- Cukesparse.parameters[:screenheight].should eql 'SCREENHEIGHT=1024'
567
- end
568
- end
569
-
570
- context "when passed the --position parameter" do
571
- before :all do
572
- # Clear arguments as rspec passes in script path
573
- ARGV.push('test_task', '--position', '0/0')
574
- Cukesparse.parameters = {}
575
- Cukesparse.parse_argv
576
- end
577
-
578
- it "should have a parameter of xposition" do
579
- Cukesparse.parameters.should have_key :xposition
580
- end
581
-
582
- it "should have a parameter of yposition" do
583
- Cukesparse.parameters.should have_key :yposition
584
- end
585
-
586
- it "should have a xposition parameter value of XPOSITION=0" do
587
- Cukesparse.parameters[:xposition].should eql 'XPOSITION=0'
588
- end
589
-
590
- it "should have a yposition parameter value of YPOSITION=0" do
591
- Cukesparse.parameters[:yposition].should eql 'YPOSITION=0'
592
- end
593
- end
594
-
595
- context "when passed the --screenwidth parameter" do
596
- before :all do
597
- # Clear arguments as rspec passes in script path
598
- ARGV.push('test_task', '--screenwidth', '1280')
599
- Cukesparse.parameters = {}
600
- Cukesparse.parse_argv
601
- end
602
-
603
- it "should have a parameter of screenwidth" do
604
- Cukesparse.parameters.should have_key :screen_width
605
- end
606
-
607
- it "should have a screenwidth parameter value of SCREENWIDTH=1280" do
608
- Cukesparse.parameters[:screen_width].should eql 'SCREENWIDTH=1280'
609
- end
610
- end
611
-
612
- context "when passed the --screenheight parameter" do
613
- before :all do
614
- # Clear arguments as rspec passes in script path
615
- ARGV.push('test_task', '--screenheight', '1024')
616
- Cukesparse.parameters = {}
617
- Cukesparse.parse_argv
618
- end
619
-
620
- it "should have a parameter of screenheight" do
621
- Cukesparse.parameters.should have_key :screen_height
622
- end
623
-
624
- it "should have a screenheight parameter value of SCREENHEIGHT=1024" do
625
- Cukesparse.parameters[:screen_height].should eql 'SCREENHEIGHT=1024'
626
- end
627
- end
628
-
629
- context "when passed the --xposition parameter" do
630
- before :all do
631
- # Clear arguments as rspec passes in script path
632
- ARGV.push('test_task', '--xposition', '100')
633
- Cukesparse.parameters = {}
634
- Cukesparse.parse_argv
635
- end
636
-
637
- it "should have a parameter of xposition" do
638
- Cukesparse.parameters.should have_key :xposition
639
- end
640
-
641
- it "should have a xposition parameter value of XPOSITION=100" do
642
- Cukesparse.parameters[:xposition].should eql 'XPOSITION=100'
643
- end
644
- end
645
-
646
- context "when passed the --yposition parameter" do
647
- before :all do
648
- # Clear arguments as rspec passes in script path
649
- ARGV.push('test_task', '--yposition', '100')
650
- Cukesparse.parameters = {}
651
- Cukesparse.parse_argv
652
- end
653
-
654
- it "should have a parameter of yposition" do
655
- Cukesparse.parameters.should have_key :yposition
656
- end
657
-
658
- it "should have a yposition parameter value of YPOSITION=100" do
659
- Cukesparse.parameters[:yposition].should eql 'YPOSITION=100'
660
- end
661
- end
662
-
663
- context "when passed the -H parameter" do
664
- before :all do
665
- # Clear arguments as rspec passes in script path
666
- ARGV.push('test_task', '-H')
667
- Cukesparse.parameters = {}
668
- Cukesparse.parse_argv
669
- end
670
-
671
- it "should have a parameter of highlight" do
672
- Cukesparse.parameters.should have_key :highlight
673
- end
674
-
675
- it "should have a highlight parameter value of HIGHLIGHT=TRUE" do
676
- Cukesparse.parameters[:highlight].should eql 'HIGHLIGHT=TRUE'
677
- end
678
- end
679
-
680
- context "when passed the --highlight parameter" do
681
- before :all do
682
- # Clear arguments as rspec passes in script path
683
- ARGV.push('test_task', '--highlight')
684
- Cukesparse.parameters = {}
685
- Cukesparse.parse_argv
686
- end
687
-
688
- it "should have a parameter of highlight" do
689
- Cukesparse.parameters.should have_key :highlight
690
- end
691
-
692
- it "should have a highlight parameter value of HIGHLIGHT=TRUE" do
693
- Cukesparse.parameters[:highlight].should eql 'HIGHLIGHT=TRUE'
694
- end
695
- end
696
-
697
- context "when passed the --debug parameter" do
698
- before :all do
699
- # Clear arguments as rspec passes in script path
700
- ARGV.push('test_task', '--debug')
701
- Cukesparse.parameters = {}
702
- Cukesparse.parse_argv
703
- end
704
-
705
- it "should have a parameter of debug" do
706
- Cukesparse.parameters.should have_key :debug
707
- end
708
-
709
- it "should have a debug parameter value of DEBUG=TRUE" do
710
- Cukesparse.parameters[:debug].should eql 'DEBUG=TRUE'
711
- end
712
- end
713
-
714
- # check_for_tasks
715
- context "when task is defined the @task instance variable will return a hash" do
716
- it "will set the task in @task" do
717
- ARGV.push('test_task')
718
- Cukesparse.configure {|c| c.config_file = './spec/spec_files/valid_tasks.yml'}
719
- Cukesparse.load_config
720
- Cukesparse.check_for_task
721
- Cukesparse.task.should be_an_instance_of Hash
722
- end
723
- end
724
-
725
- # default_parameters
726
- context "when running the test task runtime default vars should be set when no arguments passed" do
727
- before :all do
728
- # Clear arguments as rspec passes in script path
729
- # Adding test tag to prevent raise
730
- ARGV.push('test_task', '-t', 'test')
731
- Cukesparse.parameters = {}
732
- Cukesparse.configure {|c| c.config_file = './spec/spec_files/valid_tasks.yml'}
733
- Cukesparse.load_config.parse_argv
734
- Cukesparse.check_for_task
735
- Cukesparse.check_for_parameters
736
- Cukesparse.set_runtime_defaults
737
- end
738
-
739
- it "should have runtime default parameters" do
740
- Cukesparse.parameters.should have_key :environment
741
- Cukesparse.parameters.should have_key :log_level
742
- Cukesparse.parameters.should have_key :cleanup
743
- Cukesparse.parameters.should have_key :database
744
- Cukesparse.parameters.should have_key :jenkins
745
- Cukesparse.parameters.should have_key :retries
746
- Cukesparse.parameters.should have_key :timeout
747
- Cukesparse.parameters.should have_key :screenwidth
748
- Cukesparse.parameters.should have_key :screenheight
749
- Cukesparse.parameters.should have_key :xposition
750
- Cukesparse.parameters.should have_key :yposition
751
- Cukesparse.parameters.should have_key :highlight
752
- end
753
-
754
- it "should have the expected default runtime parameter values" do
755
- Cukesparse.parameters[:environment].should eql 'ENVIRONMENT=release'
756
- Cukesparse.parameters[:log_level].should eql 'LOG_LEVEL=debug'
757
- Cukesparse.parameters[:cleanup].should eql 'CLEANUP=true'
758
- Cukesparse.parameters[:database].should eql 'DATABASE=true'
759
- Cukesparse.parameters[:jenkins].should eql 'JENKINS=true'
760
- Cukesparse.parameters[:retries].should eql 'RETRIES=5'
761
- Cukesparse.parameters[:timeout].should eql 'TIMEOUT=60'
762
- Cukesparse.parameters[:screenwidth].should eql 'SCREENWIDTH=1280'
763
- Cukesparse.parameters[:screenheight].should eql 'SCREENHEIGHT=1024'
764
- Cukesparse.parameters[:xposition].should eql 'XPOSITION=0'
765
- Cukesparse.parameters[:yposition].should eql 'YPOSITION=0'
766
- Cukesparse.parameters[:highlight].should eql 'HIGHLIGHT=true'
767
- end
768
- end
769
-
770
- context "when running the test task cucumber default vars should be set when no arguments passed" do
771
- before :all do
772
- # Clear arguments as rspec passes in script path
773
- # Adding test tag to prevent raise
774
- ARGV.push('test_task', '-t', 'test')
775
- Cukesparse.parameters = {}
776
- Cukesparse.configure {|c| c.config_file = './spec/spec_files/valid_tasks.yml'}
777
- Cukesparse.load_config.parse_argv
778
- Cukesparse.check_for_task
779
- Cukesparse.check_for_parameters
780
- Cukesparse.set_cucumber_defaults
781
- end
782
-
783
- it "should have cucumber default parameters" do
784
- Cukesparse.parameters.should have_key :format
785
- Cukesparse.parameters.should have_key :name
786
- Cukesparse.parameters.should have_key :tags
787
- Cukesparse.parameters.should have_key :strict
788
- Cukesparse.parameters.should have_key :verbose
789
- Cukesparse.parameters.should have_key :dry_run
790
- Cukesparse.parameters.should have_key :guess
791
- Cukesparse.parameters.should have_key :expand
792
- end
793
-
794
- it "should have the expected default runtime parameter values" do
795
- Cukesparse.parameters[:format].should eql '--format pretty'
796
- Cukesparse.parameters[:name].should eql ['--name feature1', '--name feature2']
797
- Cukesparse.parameters[:tags].should eql ['--tags test', '--tags tags1', '--tags tags2']
798
- Cukesparse.parameters[:strict].should eql '--strict'
799
- Cukesparse.parameters[:verbose].should eql '--verbose'
800
- Cukesparse.parameters[:dry_run].should eql '--dry-run'
801
- Cukesparse.parameters[:guess].should eql '--guess'
802
- Cukesparse.parameters[:expand].should eql '--expand'
803
- end
804
- end
805
-
806
- # add_multiple
807
- context "when add_multiple is called with a single value" do
808
- before do
809
- Cukesparse.parameters = {}
810
- end
811
-
812
- it "will add a key to parameters with the correct array value" do
813
- Cukesparse.add_multiple(:tags, 'abc')
814
- Cukesparse.parameters.should have_key(:tags)
815
- Cukesparse.parameters[:tags].should eql ['--tags abc']
816
- end
817
- end
818
-
819
- context "when add_multiple is called with multiple values" do
820
- before do
821
- Cukesparse.parameters = {}
822
- end
823
-
824
- it "will add a key to parameters with the correct array values" do
825
- Cukesparse.add_multiple(:tags, ['abc', 'def', 'hij'])
826
- Cukesparse.parameters.should have_key(:tags)
827
- Cukesparse.parameters[:tags].should eql ['--tags abc', '--tags def', '--tags hij']
828
- end
829
- end
830
-
831
- # split_parameters
832
- context "when split parameters sends :screen symbol with arguments" do
833
- before do
834
- Cukesparse.parameters = {}
835
- end
836
-
837
- it "will return set a parameters screen key and value" do
838
- Cukesparse.split_parameters('1024/1280', :screen)
839
- Cukesparse.parameters.should have_key(:screenwidth)
840
- Cukesparse.parameters.should have_key(:screenheight)
841
- Cukesparse.parameters[:screenwidth].should eql "SCREENWIDTH=1024"
842
- Cukesparse.parameters[:screenheight].should eql "SCREENHEIGHT=1280"
843
- end
844
- end
845
-
846
- context "when split parameters sends :position symbol with arguments" do
847
- before do
848
- Cukesparse.parameters = {}
849
- end
850
-
851
- it "will return set a parameters screen key and value" do
852
- Cukesparse.split_parameters('0/100', :position)
853
- Cukesparse.parameters.should have_key(:xposition)
854
- Cukesparse.parameters.should have_key(:yposition)
855
- Cukesparse.parameters[:xposition].should eql "XPOSITION=0"
856
- Cukesparse.parameters[:yposition].should eql "YPOSITION=100"
857
- end
858
- end
859
-
860
- # CLI
861
- context "when CLI is run with incorrect ARGV array" do
862
- it "will return an error if arguments are nil" do
863
- ARGV.push(nil)
864
- Cukesparse.should_receive("abort").with("\e[4;31;49mError processing passed CLI arguments!\e[0m")
865
- Cukesparse.parse_argv
866
- end
867
- end
868
-
869
- context "when CLI is run with incorrect task file" do
870
- it "will return an error if the task file fails to parse" do
871
- Cukesparse.configure {|c| c.config_file = './spec/spec_files/invalid_tasks.yml'}
872
- Cukesparse.should_receive("abort").with("\e[4;31;49mYour tasks file did not parse as expected!\e[0m")
873
- Cukesparse.load_config
874
- end
875
- end
876
-
877
- context "when CLI is run with task file missing" do
878
- it "will return an error if the task file is missing" do
879
- Cukesparse.configure {|c| c.config_file = './spec/spec_files/missing_tasks.yml'}
880
- Cukesparse.should_receive("abort").with("\e[4;31;49mYour tasks file is missing!\e[0m")
881
- Cukesparse.load_config
882
- end
883
- end
884
-
885
- context "when CLI is run with no task defined" do
886
- it "will return an error if no task is provided" do
887
- ARGV.push('incorrect_task')
888
- Cukesparse.config = {}
889
- Cukesparse.should_receive("abort").with("\e[4;31;49mERROR: No task was passed to cukesparse!\e[0m")
890
- Cukesparse.check_for_task
891
- end
892
- end
893
-
894
- context "when CLI is run with multiple tasks defined" do
895
- it "will return an error if multiple tasks are provided" do
896
- ARGV.push('test_task', 'test_task1')
897
- Cukesparse.configure {|c| c.config_file = './spec/spec_files/valid_tasks.yml'}
898
- Cukesparse.load_config
899
- Cukesparse.should_receive("puts").with("\e[0;33;49mWARN: Multiple tasks have been passed!\e[0m")
900
- Cukesparse.check_for_task
901
- end
902
- end
903
-
904
- context "when CLI is run with no paramaters defined" do
905
- it "will return an warning if no parameters are provided" do
906
- Cukesparse.instance_variable_set(:@parameters, {})
907
- Cukesparse.should_receive("puts").with("\e[0;33;49mWARN: No parameters passed to cukesparse\e[0m")
908
- Cukesparse.check_for_parameters
909
- end
910
- end
911
-
912
- context "when CLI is run with no runtime_defaults defined" do
913
- it "will return a warning if no runtime_defaults are provided" do
914
- ARGV.push('no_defaults')
915
- Cukesparse.configure {|c| c.config_file = './spec/spec_files/valid_tasks.yml'}
916
- Cukesparse.load_config
917
- Cukesparse.check_for_task
918
- Cukesparse.should_receive("puts").with("\e[0;33;49mWARN: The task has no runtime defaults!\e[0m")
919
- Cukesparse.set_runtime_defaults
920
- end
921
- end
922
-
923
- context "when CLI is run with no cucumber_defaults defined" do
924
- it "will return a warning if no cucumber_defaults are provided" do
925
- ARGV.push('no_defaults')
926
- Cukesparse.configure {|c| c.config_file = './spec/spec_files/valid_tasks.yml'}
927
- Cukesparse.load_config
928
- Cukesparse.check_for_task
929
- Cukesparse.should_receive("puts").with("\e[0;33;49mWARN: The task has no cucumber defaults!\e[0m")
930
- Cukesparse.set_cucumber_defaults
931
- end
932
- end
933
-
934
- context "when CLI is run with and split paramters which sends one argument" do
935
- it "will return a error" do
936
- Cukesparse.should_receive("abort").with("\e[4;31;49mERROR: You have not passed enough parameters in the test command line argument!\e[0m")
937
- Cukesparse.split_parameters('1024', :test)
938
- end
939
- end
940
-
941
- context "when CLI is run with and split paramters which over two argument" do
942
- it "will return a error" do
943
- Cukesparse.should_receive("abort").with("\e[4;31;49mERROR: You have passed to many parameters in the test command line argument!\e[0m")
944
- Cukesparse.split_parameters('1024/1280/16', :test)
945
- end
946
- end
947
30
  end