cukesparse 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ OGEyMTU2NjMwMDQ3NjVkNzc1NDMwZmU3NWZlMWY4ZjE0MDRjMGJjOA==
5
+ data.tar.gz: !binary |-
6
+ NjcyZDBiYTRlOWYwYWIyMjFmZDRhMWE2ZWM5YmZlYzZlYjNmNDhlMQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ NTE2ZDRlMGUzY2VmYmIxN2M2ODY5ZGFmZjk3YmExYWU3NzBiNmY0MzhiZjQ2
10
+ YTAwNTMzZWJlOTJiYjc5ZTQxZDE5ODE1YzQxZTE5MWYxZTM1OTQ2ZjkzNjEy
11
+ MTM5OGM0ZjRkNDlkOWQ4NGQxNDdhODA0NDZhYTdjYTA3NDg5YTU=
12
+ data.tar.gz: !binary |-
13
+ ODYwOWYwZTA2ZmViYjQ3OWQ1NWQzNjc3NWM5ZGZhY2I0ZmVkM2E4Y2I2NTY0
14
+ MGQxYWY1YjQyYjQ1MzAzYzFjNDZmNThkY2NlZjljMDYwZDdiOGZmMTQ1NzQ5
15
+ YzE1YzRmNDY0N2RhM2U3YTQ3OGU4ZTA0MGE1MjU2MDI1OGI0YTM=
data/bin/cukesparse ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require 'cukesparse'
3
+ Cukesparse.new.parse_options.build_command
data/lib/cukesparse.rb ADDED
@@ -0,0 +1,171 @@
1
+ require 'clik'
2
+ require 'yaml'
3
+ require 'colored'
4
+
5
+ class Cukesparse
6
+
7
+ attr_reader :parameters, :args
8
+ attr_accessor :config
9
+
10
+ def initialize
11
+ @config = load_config('config/tasks.yml')
12
+ @args = ARGV
13
+ @parameters = {}
14
+ @task = {}
15
+ @command = []
16
+ end
17
+
18
+ # Parses the options passed via command line
19
+ def parse_options
20
+ begin
21
+ cli @args,
22
+ # Cucumber options
23
+ '-t' => lambda{ |t| add_multiple(:tags, t) },
24
+ '-n --name' => lambda{ |n| @parameters[:name] = "--name #{n}" },
25
+ '-f --format' => ->(f){ @parameters[:format] = "--format #{f}" },
26
+ '-d --dry-run' => ->{ @parameters[:dry_run] = "--dry-run" },
27
+ '-v --verbose' => ->{ @parameters[:verbose] = "--verbose" },
28
+ '-s --strict' => ->{ @parameters[:strict] = "--strict" },
29
+ '-g --guess' => ->{ @parameters[:guess] = "--guess" },
30
+ '-x --expand' => ->{ @parameters[:expand] = "--expand" },
31
+
32
+ # All options below have been added for custom project but can be used for example
33
+ # Global options
34
+ '-e --environment' => ->(e){ @parameters[:environment] = "ENVIRONMENT=#{e}" },
35
+ '-l --loglevel' => ->(l){ @parameters[:log_level] = "LOG_LEVEL=#{l}" },
36
+ '-c --controller' => ->(c){ @parameters[:controller] = "CONTROLLER=#{c}" },
37
+ '-h --headless' => ->{ @parameters[:headless] = "HEADLESS=TRUE" },
38
+
39
+ # Database options
40
+ '--cleanup' => ->{ @parameters[:cleanup] = "CLEANUP=TRUE" },
41
+ '--no-cleanup' => ->{ @parameters[:cleanup] = "CLEANUP=FALSE" },
42
+ '--database' => ->{ @parameters[:database] = "DATABASE=TRUE" },
43
+ '--jenkins' => ->{ @parameters[:jenkins] = "JENKINS=TRUE" },
44
+
45
+ # Retry options
46
+ '--retries' => ->(r){ @parameters[:retries] = "RETRIES=#{r}" },
47
+ '--timeout' => ->(t){ @parameters[:timeout] = "TIMEOUT=#{t}" },
48
+
49
+ # Driver Options
50
+ '--screen' => ->(s){ split_parameters(s, :screen) },
51
+ '--position' => ->(p){ split_parameters(p, :position) },
52
+ '--screenwidth' => ->(w){ @parameters[:screen_width] = "SCREENWIDTH=#{w}" },
53
+ '--screenheight' => ->(h){ @parameters[:screen_height] = "SCREENHEIGHT=#{h}" },
54
+ '--xposition' => ->(x){ @parameters[:xposition] = "XPOSITION=#{x}" },
55
+ '--yposition' => ->(y){ @parameters[:yposition] = "YPOSITION=#{y}" },
56
+ '-H --highlight' => ->{ @parameters[:highlight] = "HIGHLIGHT=TRUE" },
57
+
58
+ # Debug
59
+ '--debug' => ->{ @parameters[:debug] = "DEBUG=TRUE" }
60
+ rescue
61
+ abort 'Error processing passed CLI arguments!'.red.underline
62
+ else
63
+ self
64
+ end
65
+ end
66
+
67
+ # Builds the command line string
68
+ def build_command
69
+ check_for_task
70
+ check_for_parameters
71
+
72
+ unless @task.empty? && @parameters.empty?
73
+ @command.push 'bundle exec cucumber'
74
+ @command.push '--require features/'
75
+ @command.push @task['feature_order'].join(' ')
76
+ @parameters.each { |k,v| @command.push(v) }
77
+ @command.push @task['defaults'].join(' ')
78
+ end
79
+
80
+ if @parameters.has_key? :debug
81
+ debug
82
+ else
83
+ system @command.join(' ')
84
+ end
85
+ end
86
+
87
+ def debug
88
+ puts 'DEBUG: Outputting ARGV passed'.yellow
89
+ puts @args.inspect
90
+ puts 'DEBUG: Outputting parameters created'.yellow
91
+ puts @parameters.inspect
92
+ puts 'DEBUG: Outputting command line created'.yellow
93
+ puts @command.join(' ')
94
+ end
95
+
96
+ # Loads the config file
97
+ #
98
+ # @param [String] file the location of tasks.yml
99
+ def load_config(file)
100
+ begin
101
+ return YAML.load_file(file)
102
+ rescue Psych::SyntaxError
103
+ abort 'Your tasks.yml did not parse as expected!'.red.underline
104
+ rescue Exception
105
+ abort 'Your tasks.yml file is missing!'.red.underline
106
+ end
107
+ end
108
+
109
+ # Checks for task in arguments
110
+ def check_for_task
111
+ @task = @args & @config.keys
112
+ if @task.empty?
113
+ abort 'ERROR: No task was passed to cukesparse!'.red.underline
114
+ elsif @task.length > 1
115
+ abort 'ERROR: Multiple tasks have been passed!'.red.underline
116
+ else
117
+ @task = @config[@task[0]]
118
+ end
119
+ end
120
+
121
+ # Checks parameters and returns boolean
122
+ def check_for_parameters
123
+ unless @parameters.any?
124
+ puts 'WARN: No parameters passed to cukesparse'.yellow
125
+ end
126
+
127
+ set_runtime_defaults
128
+ end
129
+
130
+ # Updates parameters based on config runtime defaults
131
+ def set_runtime_defaults
132
+ if @task.has_key?('runtime_defaults')
133
+ @task['runtime_defaults'].each do |key, value|
134
+ unless @parameters.has_key? key.to_sym
135
+ @parameters[key.to_sym] = key.upcase + '=' + value.to_s
136
+ end
137
+ end
138
+ else
139
+ puts 'WARN: The task has no runtime defaults!'.yellow
140
+ end
141
+ end
142
+
143
+ # Add multiple options to key
144
+ #
145
+ # @param [Symbol] key the key to store in options
146
+ # @param [String] the arguments passed in for key
147
+ def add_multiple(key, args)
148
+ (@parameters[key] ||= []).push('--' + key.to_s + ' ' + args)
149
+ end
150
+
151
+ # Splits parameters passed
152
+ #
153
+ # @param [String] parameters the parameters passed
154
+ # @param [Symbol] sym the symbol passed
155
+ def split_parameters(parameters, sym)
156
+ parameters = parameters.split(',')
157
+ if parameters.length == 1
158
+ abort "ERROR: You have not passed enough parameters in the #{sym.to_s} command line argument!".red.underline
159
+ elsif parameters.length > 2
160
+ abort "ERROR: You have passed to many parameters in the #{sym.to_s} command line argument!".red.underline
161
+ end
162
+
163
+ case sym
164
+ when :screen
165
+ @parameters[sym] = "SCREENWIDTH=#{parameters[0]} SCREENHEIGHT=#{parameters[1]}"
166
+ when :position
167
+ @parameters[sym] = "XPOSITION=#{parameters[0]} YPOSITION=#{parameters[1]}"
168
+ end
169
+ end
170
+
171
+ end
@@ -0,0 +1,666 @@
1
+ require 'cukesparse'
2
+ require 'colored'
3
+ require 'rspec'
4
+
5
+ describe "cukesparse" do
6
+
7
+ # Object
8
+ context "when new" do
9
+ before :all do
10
+ # Clear arguments as rspec passes in script path
11
+ ARGV = []
12
+ @cukesparse = Cukesparse.new
13
+ end
14
+
15
+ it "should be an instance of cukesparse" do
16
+ @cukesparse.should be_an_instance_of Cukesparse
17
+ end
18
+
19
+ it "returns true for empty opts parameter" do
20
+ @cukesparse.parameters.should be_empty
21
+ end
22
+
23
+ it "returns true for empty args parameter" do
24
+ @cukesparse.args.should be_empty
25
+ end
26
+ end
27
+
28
+ # Parameters
29
+ context "when passed the -t parameter" do
30
+ before :all do
31
+ # Clear arguments as rspec passes in script path
32
+ ARGV = ['test_task', '-t', 'test']
33
+ @cukesparse = Cukesparse.new
34
+ @cukesparse.parse_options
35
+ end
36
+
37
+ it "should have a parameter of tags" do
38
+ @cukesparse.parameters.should have_key :tags
39
+ end
40
+
41
+ it "should have a tags parameter value of --tags test" do
42
+ @cukesparse.parameters[:tags].should eql ['--tags test']
43
+ end
44
+ end
45
+
46
+ context "when passed the -n parameter" do
47
+ before :all do
48
+ # Clear arguments as rspec passes in script path
49
+ ARGV = ['test_task', '-n', 'name_test']
50
+ @cukesparse = Cukesparse.new
51
+ @cukesparse.parse_options
52
+ end
53
+
54
+ it "should have a parameter of name" do
55
+ @cukesparse.parameters.should have_key :name
56
+ end
57
+
58
+ it "should have a tags parameter value of test" do
59
+ @cukesparse.parameters[:name].should eql '--name name_test'
60
+ end
61
+ end
62
+
63
+ context "when passed the -name parameter" do
64
+ before :all do
65
+ # Clear arguments as rspec passes in script path
66
+ ARGV = ['test_task', '--name', 'name_test']
67
+ @cukesparse = Cukesparse.new
68
+ @cukesparse.parse_options
69
+ end
70
+
71
+ it "should have a parameter of name" do
72
+ @cukesparse.parameters.should have_key :name
73
+ end
74
+
75
+ it "should have a tags parameter value of test" do
76
+ @cukesparse.parameters[:name].should eql '--name name_test'
77
+ end
78
+ end
79
+
80
+ context "when passed the -d parameter" do
81
+ before :all do
82
+ # Clear arguments as rspec passes in script path
83
+ ARGV = ['test_task', '-d']
84
+ @cukesparse = Cukesparse.new
85
+ @cukesparse.parse_options
86
+ end
87
+
88
+ it "should have a parameter of name" do
89
+ @cukesparse.parameters.should have_key :dry_run
90
+ end
91
+
92
+ it "should have a dry_run parameter value of --dry-run" do
93
+ @cukesparse.parameters[:dry_run].should eql '--dry-run'
94
+ end
95
+ end
96
+
97
+ context "when passed the --dry-run parameter" do
98
+ before :all do
99
+ # Clear arguments as rspec passes in script path
100
+ ARGV = ['test_task', '--dry-run']
101
+ @cukesparse = Cukesparse.new
102
+ @cukesparse.parse_options
103
+ end
104
+
105
+ it "should have a parameter of dry_run" do
106
+ @cukesparse.parameters.should have_key :dry_run
107
+ end
108
+
109
+ it "should have a dry_run parameter value of --dry-run" do
110
+ @cukesparse.parameters[:dry_run].should eql '--dry-run'
111
+ end
112
+ end
113
+
114
+ context "when passed the -v parameter" do
115
+ before :all do
116
+ # Clear arguments as rspec passes in script path
117
+ ARGV = ['test_task', '-v']
118
+ @cukesparse = Cukesparse.new
119
+ @cukesparse.parse_options
120
+ end
121
+
122
+ it "should have a parameter of verbose" do
123
+ @cukesparse.parameters.should have_key :verbose
124
+ end
125
+
126
+ it "should have a verbose parameter value of --verbose" do
127
+ @cukesparse.parameters[:verbose].should eql '--verbose'
128
+ end
129
+ end
130
+
131
+ context "when passed the --verbose parameter" do
132
+ before :all do
133
+ # Clear arguments as rspec passes in script path
134
+ ARGV = ['test_task', '--verbose']
135
+ @cukesparse = Cukesparse.new
136
+ @cukesparse.parse_options
137
+ end
138
+
139
+ it "should have a parameter of verbose" do
140
+ @cukesparse.parameters.should have_key :verbose
141
+ end
142
+
143
+ it "should have a verbose parameter value of --verbose" do
144
+ @cukesparse.parameters[:verbose].should eql '--verbose'
145
+ end
146
+ end
147
+
148
+ context "when passed the -s parameter" do
149
+ before :all do
150
+ # Clear arguments as rspec passes in script path
151
+ ARGV = ['test_task', '-s']
152
+ @cukesparse = Cukesparse.new
153
+ @cukesparse.parse_options
154
+ end
155
+
156
+ it "should have a parameter of strict" do
157
+ @cukesparse.parameters.should have_key :strict
158
+ end
159
+
160
+ it "should have a strict parameter value of --strict" do
161
+ @cukesparse.parameters[:strict].should eql '--strict'
162
+ end
163
+ end
164
+
165
+ context "when passed the --strict parameter" do
166
+ before :all do
167
+ # Clear arguments as rspec passes in script path
168
+ ARGV = ['test_task', '-s']
169
+ @cukesparse = Cukesparse.new
170
+ @cukesparse.parse_options
171
+ end
172
+
173
+ it "should have a parameter of --strict" do
174
+ @cukesparse.parameters.should have_key :strict
175
+ end
176
+
177
+ it "should have a strict parameter value of --strict" do
178
+ @cukesparse.parameters[:strict].should eql '--strict'
179
+ end
180
+ end
181
+
182
+ context "when passed the -g parameter" do
183
+ before :all do
184
+ # Clear arguments as rspec passes in script path
185
+ ARGV = ['test_task', '-g']
186
+ @cukesparse = Cukesparse.new
187
+ @cukesparse.parse_options
188
+ end
189
+
190
+ it "should have a parameter of --guess" do
191
+ @cukesparse.parameters.should have_key :guess
192
+ end
193
+
194
+ it "should have a strict parameter value of --guess" do
195
+ @cukesparse.parameters[:guess].should eql '--guess'
196
+ end
197
+ end
198
+
199
+ context "when passed the --guess parameter" do
200
+ before :all do
201
+ # Clear arguments as rspec passes in script path
202
+ ARGV = ['test_task', '--guess']
203
+ @cukesparse = Cukesparse.new
204
+ @cukesparse.parse_options
205
+ end
206
+
207
+ it "should have a parameter of --guess" do
208
+ @cukesparse.parameters.should have_key :guess
209
+ end
210
+
211
+ it "should have a strict parameter value of --guess" do
212
+ @cukesparse.parameters[:guess].should eql '--guess'
213
+ end
214
+ end
215
+
216
+ context "when passed the -x parameter" do
217
+ before :all do
218
+ # Clear arguments as rspec passes in script path
219
+ ARGV = ['test_task', '-x']
220
+ @cukesparse = Cukesparse.new
221
+ @cukesparse.parse_options
222
+ end
223
+
224
+ it "should have a parameter of --expand" do
225
+ @cukesparse.parameters.should have_key :expand
226
+ end
227
+
228
+ it "should have a strict parameter value of --expand" do
229
+ @cukesparse.parameters[:expand].should eql '--expand'
230
+ end
231
+ end
232
+
233
+ context "when passed the --expand parameter" do
234
+ before :all do
235
+ # Clear arguments as rspec passes in script path
236
+ ARGV = ['test_task', '--expand']
237
+ @cukesparse = Cukesparse.new
238
+ @cukesparse.parse_options
239
+ end
240
+
241
+ it "should have a parameter of --expand" do
242
+ @cukesparse.parameters.should have_key :expand
243
+ end
244
+
245
+ it "should have a strict parameter value of --expand" do
246
+ @cukesparse.parameters[:expand].should eql '--expand'
247
+ end
248
+ end
249
+
250
+ context "when passed the -e parameter" do
251
+ before :all do
252
+ # Clear arguments as rspec passes in script path
253
+ ARGV = ['test_task', '-e', 'test_environment']
254
+ @cukesparse = Cukesparse.new
255
+ @cukesparse.parse_options
256
+ end
257
+
258
+ it "should have a parameter of environment" do
259
+ @cukesparse.parameters.should have_key :environment
260
+ end
261
+
262
+ it "should have a environment parameter value of ENVIRONMENT=test_environment" do
263
+ @cukesparse.parameters[:environment].should eql 'ENVIRONMENT=test_environment'
264
+ end
265
+ end
266
+
267
+ context "when passed the --environment parameter" do
268
+ before :all do
269
+ # Clear arguments as rspec passes in script path
270
+ ARGV = ['test_task', '--environment', 'test_environment']
271
+ @cukesparse = Cukesparse.new
272
+ @cukesparse.parse_options
273
+ end
274
+
275
+ it "should have a parameter of environment" do
276
+ @cukesparse.parameters.should have_key :environment
277
+ end
278
+
279
+ it "should have a environment parameter value of ENVIRONMENT=test_environment" do
280
+ @cukesparse.parameters[:environment].should eql 'ENVIRONMENT=test_environment'
281
+ end
282
+ end
283
+
284
+ context "when passed the -l parameter" do
285
+ before :all do
286
+ # Clear arguments as rspec passes in script path
287
+ ARGV = ['test_task', '-l', 'debug']
288
+ @cukesparse = Cukesparse.new
289
+ @cukesparse.parse_options
290
+ end
291
+
292
+ it "should have a parameter of loglevel" do
293
+ @cukesparse.parameters.should have_key :log_level
294
+ end
295
+
296
+ it "should have a loglevel parameter value of LOG_LEVEL=debug" do
297
+ @cukesparse.parameters[:log_level].should eql 'LOG_LEVEL=debug'
298
+ end
299
+ end
300
+
301
+ context "when passed the --loglevel parameter" do
302
+ before :all do
303
+ # Clear arguments as rspec passes in script path
304
+ ARGV = ['test_task', '--loglevel', 'debug']
305
+ @cukesparse = Cukesparse.new
306
+ @cukesparse.parse_options
307
+ end
308
+
309
+ it "should have a parameter of loglevel" do
310
+ @cukesparse.parameters.should have_key :log_level
311
+ end
312
+
313
+ it "should have a loglevel parameter value of LOG_LEVEL=debug" do
314
+ @cukesparse.parameters[:log_level].should eql 'LOG_LEVEL=debug'
315
+ end
316
+ end
317
+
318
+ context "when passed the -c parameter" do
319
+ before :all do
320
+ # Clear arguments as rspec passes in script path
321
+ ARGV = ['test_task', '-c', 'browser']
322
+ @cukesparse = Cukesparse.new
323
+ @cukesparse.parse_options
324
+ end
325
+
326
+ it "should have a parameter of controller" do
327
+ @cukesparse.parameters.should have_key :controller
328
+ end
329
+
330
+ it "should have a controller parameter value of CONTROLLER=browser" do
331
+ @cukesparse.parameters[:controller].should eql 'CONTROLLER=browser'
332
+ end
333
+ end
334
+
335
+ context "when passed the --controller parameter" do
336
+ before :all do
337
+ # Clear arguments as rspec passes in script path
338
+ ARGV = ['test_task', '--controller', 'browser']
339
+ @cukesparse = Cukesparse.new
340
+ @cukesparse.parse_options
341
+ end
342
+
343
+ it "should have a parameter of controller" do
344
+ @cukesparse.parameters.should have_key :controller
345
+ end
346
+
347
+ it "should have a controller parameter value of CONTROLLER=browser" do
348
+ @cukesparse.parameters[:controller].should eql 'CONTROLLER=browser'
349
+ end
350
+ end
351
+
352
+ context "when passed the -h parameter" do
353
+ before :all do
354
+ # Clear arguments as rspec passes in script path
355
+ ARGV = ['test_task', '-h']
356
+ @cukesparse = Cukesparse.new
357
+ @cukesparse.parse_options
358
+ end
359
+
360
+ it "should have a parameter of headless" do
361
+ @cukesparse.parameters.should have_key :headless
362
+ end
363
+
364
+ it "should have a headless parameter value of HEADLESS=TRUE" do
365
+ @cukesparse.parameters[:headless].should eql 'HEADLESS=TRUE'
366
+ end
367
+ end
368
+
369
+ context "when passed the --headless parameter" do
370
+ before :all do
371
+ # Clear arguments as rspec passes in script path
372
+ ARGV = ['test_task', '--headless']
373
+ @cukesparse = Cukesparse.new
374
+ @cukesparse.parse_options
375
+ end
376
+
377
+ it "should have a parameter of headless" do
378
+ @cukesparse.parameters.should have_key :headless
379
+ end
380
+
381
+ it "should have a headless parameter value of HEADLESS=TRUE" do
382
+ @cukesparse.parameters[:headless].should eql 'HEADLESS=TRUE'
383
+ end
384
+ end
385
+
386
+ context "when passed the --cleanup parameter" do
387
+ before :all do
388
+ # Clear arguments as rspec passes in script path
389
+ ARGV = ['test_task', '--cleanup']
390
+ @cukesparse = Cukesparse.new
391
+ @cukesparse.parse_options
392
+ end
393
+
394
+ it "should have a parameter of cleanup" do
395
+ @cukesparse.parameters.should have_key :cleanup
396
+ end
397
+
398
+ it "should have a cleanup parameter value of CLEANUP=TRUE" do
399
+ @cukesparse.parameters[:cleanup].should eql 'CLEANUP=TRUE'
400
+ end
401
+ end
402
+
403
+ context "when passed the --no-cleanup parameter" do
404
+ before :all do
405
+ # Clear arguments as rspec passes in script path
406
+ ARGV = ['test_task', '--no-cleanup']
407
+ @cukesparse = Cukesparse.new
408
+ @cukesparse.parse_options
409
+ end
410
+
411
+ it "should have a parameter of cleanup" do
412
+ @cukesparse.parameters.should have_key :cleanup
413
+ end
414
+
415
+ it "should have a cleanup parameter value of CLEANUP=FALSE" do
416
+ @cukesparse.parameters[:cleanup].should eql 'CLEANUP=FALSE'
417
+ end
418
+ end
419
+
420
+ context "when passed the --database parameter" do
421
+ before :all do
422
+ # Clear arguments as rspec passes in script path
423
+ ARGV = ['test_task', '--database']
424
+ @cukesparse = Cukesparse.new
425
+ @cukesparse.parse_options
426
+ end
427
+
428
+ it "should have a parameter of database" do
429
+ @cukesparse.parameters.should have_key :database
430
+ end
431
+
432
+ it "should have a database parameter value of DATABASE=TRUE" do
433
+ @cukesparse.parameters[:database].should eql 'DATABASE=TRUE'
434
+ end
435
+ end
436
+
437
+ context "when passed the --jenkins parameter" do
438
+ before :all do
439
+ # Clear arguments as rspec passes in script path
440
+ ARGV = ['test_task', '--jenkins']
441
+ @cukesparse = Cukesparse.new
442
+ @cukesparse.parse_options
443
+ end
444
+
445
+ it "should have a parameter of jenkins" do
446
+ @cukesparse.parameters.should have_key :jenkins
447
+ end
448
+
449
+ it "should have a jenkins parameter value of JENKINS=TRUE" do
450
+ @cukesparse.parameters[:jenkins].should eql 'JENKINS=TRUE'
451
+ end
452
+ end
453
+
454
+ context "when passed the --retries parameter" do
455
+ before :all do
456
+ # Clear arguments as rspec passes in script path
457
+ ARGV = ['test_task', '--retries', '5']
458
+ @cukesparse = Cukesparse.new
459
+ @cukesparse.parse_options
460
+ end
461
+
462
+ it "should have a parameter of retries" do
463
+ @cukesparse.parameters.should have_key :retries
464
+ end
465
+
466
+ it "should have a retries parameter value of RETRIES=5" do
467
+ @cukesparse.parameters[:retries].should eql 'RETRIES=5'
468
+ end
469
+ end
470
+
471
+ context "when passed the --timeout parameter" do
472
+ before :all do
473
+ # Clear arguments as rspec passes in script path
474
+ ARGV = ['test_task', '--timeout', '10']
475
+ @cukesparse = Cukesparse.new
476
+ @cukesparse.parse_options
477
+ end
478
+
479
+ it "should have a parameter of timeout" do
480
+ @cukesparse.parameters.should have_key :timeout
481
+ end
482
+
483
+ it "should have a timeout parameter value of TIMEOUT=10" do
484
+ @cukesparse.parameters[:timeout].should eql 'TIMEOUT=10'
485
+ end
486
+ end
487
+
488
+ context "when passed the --screen parameter" do
489
+ before :all do
490
+ # Clear arguments as rspec passes in script path
491
+ ARGV = ['test_task', '--screen', '1280,1024']
492
+ @cukesparse = Cukesparse.new
493
+ @cukesparse.parse_options
494
+ end
495
+
496
+ it "should have a parameter of screen" do
497
+ @cukesparse.parameters.should have_key :screen
498
+ end
499
+
500
+ it "should have a screen parameter value of SCREENWIDTH=1280 SCREENHEIGHT=1024" do
501
+ @cukesparse.parameters[:screen].should eql 'SCREENWIDTH=1280 SCREENHEIGHT=1024'
502
+ end
503
+ end
504
+
505
+ context "when passed the --position parameter" do
506
+ before :all do
507
+ # Clear arguments as rspec passes in script path
508
+ ARGV = ['test_task', '--position', '0,0']
509
+ @cukesparse = Cukesparse.new
510
+ @cukesparse.parse_options
511
+ end
512
+
513
+ it "should have a parameter of position" do
514
+ @cukesparse.parameters.should have_key :position
515
+ end
516
+
517
+ it "should have a position parameter value of XPOSITION=0 YPOSITION=0" do
518
+ @cukesparse.parameters[:position].should eql 'XPOSITION=0 YPOSITION=0'
519
+ end
520
+ end
521
+
522
+ context "when passed the --screenwidth parameter" do
523
+ before :all do
524
+ # Clear arguments as rspec passes in script path
525
+ ARGV = ['test_task', '--screenwidth', '1280']
526
+ @cukesparse = Cukesparse.new
527
+ @cukesparse.parse_options
528
+ end
529
+
530
+ it "should have a parameter of screenwidth" do
531
+ @cukesparse.parameters.should have_key :screen_width
532
+ end
533
+
534
+ it "should have a screenwidth parameter value of SCREENWIDTH=1280" do
535
+ @cukesparse.parameters[:screen_width].should eql 'SCREENWIDTH=1280'
536
+ end
537
+ end
538
+
539
+ context "when passed the --screenheight parameter" do
540
+ before :all do
541
+ # Clear arguments as rspec passes in script path
542
+ ARGV = ['test_task', '--screenheight', '1024']
543
+ @cukesparse = Cukesparse.new
544
+ @cukesparse.parse_options
545
+ end
546
+
547
+ it "should have a parameter of screenheight" do
548
+ @cukesparse.parameters.should have_key :screen_height
549
+ end
550
+
551
+ it "should have a screenheight parameter value of SCREENHEIGHT=1024" do
552
+ @cukesparse.parameters[:screen_height].should eql 'SCREENHEIGHT=1024'
553
+ end
554
+ end
555
+
556
+ context "when passed the --xposition parameter" do
557
+ before :all do
558
+ # Clear arguments as rspec passes in script path
559
+ ARGV = ['test_task', '--xposition', '100']
560
+ @cukesparse = Cukesparse.new
561
+ @cukesparse.parse_options
562
+ end
563
+
564
+ it "should have a parameter of xposition" do
565
+ @cukesparse.parameters.should have_key :xposition
566
+ end
567
+
568
+ it "should have a xposition parameter value of XPOSITION=100" do
569
+ @cukesparse.parameters[:xposition].should eql 'XPOSITION=100'
570
+ end
571
+ end
572
+
573
+ context "when passed the --yposition parameter" do
574
+ before :all do
575
+ # Clear arguments as rspec passes in script path
576
+ ARGV = ['test_task', '--yposition', '100']
577
+ @cukesparse = Cukesparse.new
578
+ @cukesparse.parse_options
579
+ end
580
+
581
+ it "should have a parameter of yposition" do
582
+ @cukesparse.parameters.should have_key :yposition
583
+ end
584
+
585
+ it "should have a yposition parameter value of YPOSITION=100" do
586
+ @cukesparse.parameters[:yposition].should eql 'YPOSITION=100'
587
+ end
588
+ end
589
+
590
+ context "when passed the -H parameter" do
591
+ before :all do
592
+ # Clear arguments as rspec passes in script path
593
+ ARGV = ['test_task', '-H']
594
+ @cukesparse = Cukesparse.new
595
+ @cukesparse.parse_options
596
+ end
597
+
598
+ it "should have a parameter of highlight" do
599
+ @cukesparse.parameters.should have_key :highlight
600
+ end
601
+
602
+ it "should have a highlight parameter value of HIGHLIGHT=TRUE" do
603
+ @cukesparse.parameters[:highlight].should eql 'HIGHLIGHT=TRUE'
604
+ end
605
+ end
606
+
607
+ context "when passed the --highlight parameter" do
608
+ before :all do
609
+ # Clear arguments as rspec passes in script path
610
+ ARGV = ['test_task', '--highlight']
611
+ @cukesparse = Cukesparse.new
612
+ @cukesparse.parse_options
613
+ end
614
+
615
+ it "should have a parameter of highlight" do
616
+ @cukesparse.parameters.should have_key :highlight
617
+ end
618
+
619
+ it "should have a highlight parameter value of HIGHLIGHT=TRUE" do
620
+ @cukesparse.parameters[:highlight].should eql 'HIGHLIGHT=TRUE'
621
+ end
622
+ end
623
+
624
+ context "when passed the --debug parameter" do
625
+ before :all do
626
+ # Clear arguments as rspec passes in script path
627
+ ARGV = ['test_task', '--debug']
628
+ @cukesparse = Cukesparse.new
629
+ @cukesparse.parse_options
630
+ end
631
+
632
+ it "should have a parameter of debug" do
633
+ @cukesparse.parameters.should have_key :debug
634
+ end
635
+
636
+ it "should have a debug parameter value of DEBUG=TRUE" do
637
+ @cukesparse.parameters[:debug].should eql 'DEBUG=TRUE'
638
+ end
639
+ end
640
+
641
+ # Default Parameters
642
+ context "when running the test task runtime default vars should be set when no arguments passed" do
643
+ before :all do
644
+ # Clear arguments as rspec passes in script path
645
+ # Adding test tag to prevent raise
646
+ ARGV = ['test_task', '-t', 'test']
647
+ @cukesparse = Cukesparse.new
648
+ @cukesparse.parse_options
649
+ @cukesparse.check_for_task
650
+ @cukesparse.check_for_parameters
651
+ end
652
+
653
+ it "should have runtime default parameters" do
654
+ @cukesparse.parameters.should have_key :environment
655
+ @cukesparse.parameters.should have_key :log_level
656
+ @cukesparse.parameters.should have_key :format
657
+ end
658
+
659
+ it "should have the expected default runtime parameter values" do
660
+ @cukesparse.parameters[:environment].should eql 'ENVIRONMENT=release'
661
+ @cukesparse.parameters[:log_level].should eql 'LOG_LEVEL=debug'
662
+ @cukesparse.parameters[:format].should eql 'FORMAT=pretty'
663
+ end
664
+ end
665
+
666
+ end
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cukesparse
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Jonathan Chrisp
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-04-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: clik
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: colored
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: A simple command line parser to pass arguments into Cucumber
42
+ email: jonathan.chrisp@gmail.com
43
+ executables:
44
+ - cukesparse
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - lib/cukesparse.rb
49
+ - test/test_cukesparse.rb
50
+ - bin/cukesparse
51
+ homepage: https://github.com/jonathanchrisp/cukesparse
52
+ licenses:
53
+ - MIT
54
+ metadata: {}
55
+ post_install_message:
56
+ rdoc_options: []
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ! '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ requirements: []
70
+ rubyforge_project:
71
+ rubygems_version: 2.0.3
72
+ signing_key:
73
+ specification_version: 4
74
+ summary: Cukesparse - cucumber command line parser
75
+ test_files:
76
+ - test/test_cukesparse.rb
77
+ has_rdoc: