cukesparse 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZThkM2M0NzRmZTk1YWZmN2IxYjMxOTJlZDdjOWYzYjhiMzNkN2IzOA==
4
+ MjYzMTY2ZjIxYmE3OTlmNzY5MGU5YzdlM2U2YTY5ZGU2MTNmNGUwMA==
5
5
  data.tar.gz: !binary |-
6
- OWMxMWQ3YTVhNTFlNmUzNTAzMjA1NDJkYzNjNGI2ZDM2OWVjNDQ4Mg==
6
+ M2E3MzEwMWNmZmJiZDY3YjUzYzUzMzAwYTM2ZjNlMDJiOTQxN2M0NA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- YWMwNjJiZWJmY2EyN2NkMTdmZDRmOTYwM2I5YmM2ODM2MTZjNjdjZWIzNjE4
10
- YTg1NGU0NDBmZDE5YzBjM2UyMzJlOTVjNmMyYWQ2NjJkNjRkYzUwYzliMDUz
11
- MzFmM2JkN2M3YTRiNGQ1ODQwY2UwMjgyMzg1MzgxYzg2YWNhODA=
9
+ YzdjMjYzMzA0N2ZhZjEzYTZiMTY4ZDI3NzZiZjUxZWRkZDMzM2RhMDgwMDJj
10
+ ZWYwMjRiYTc0NjlhZmNlYWNiNWRhZmM3MzFjYWU1NzFmZmRmMWJmMjE4ODE4
11
+ ODhlNzY0ZmEyODA0ZTdjZDEyNGVlNjE5ZTNlMGIwZDcxMzM2YjY=
12
12
  data.tar.gz: !binary |-
13
- NjM3ZTA3YTUzYWUwMTE1MjhhY2I1NTVlMTYwNWE3NjY0MzA2Njc1YTU2MzEz
14
- NTZhMGMyMDJmYzBkYTE5NTM1YTQ0MTE0ZjRiNzFlZDVhOTllNjhiZTE5NjYz
15
- ZmE2YTRkMjk4ZTVlYjkxMGM0OTllMWMxYWM3NTQ5MDJhZmFjYjA=
13
+ NzcyNjg0MTUwYjQ5MzQwNWQxMTNkYTBiOTY5MjgxMTlmMjI3MGI2NTk2MWUw
14
+ MDQyNDY2OGQyZmMxNmVmMGY4YmFhMjEzNDhhMzA5YzVlNTJmZTE2NDg2MjM0
15
+ Mjk0Mjg1OWFkMTcwODk2NGQxNjcwYTM3ZTRkNzU5NWMwNjNmZjk=
data/bin/cukesparse CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'cukesparse'
3
- Cukesparse.new.parse_options.build_command
3
+ Cukesparse.load_config.parse_argv.build_command
data/lib/cukesparse.rb CHANGED
@@ -2,170 +2,183 @@ require 'clik'
2
2
  require 'yaml'
3
3
  require 'colored'
4
4
 
5
- class Cukesparse
5
+ module Cukesparse
6
6
 
7
- attr_reader :parameters, :args
8
- attr_accessor :config
7
+ class << self
8
+ attr_accessor :config_file, :config, :task, :parameters, :command
9
9
 
10
- def initialize
11
- @config = load_config('config/tasks.yml')
12
- @args = ARGV
13
- @parameters = {}
14
- @tasks = {}
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
10
+ # configure cukeparse
11
+ def configure
12
+ yield self
64
13
  end
65
- end
66
14
 
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(' ')
15
+ # returns ARGV
16
+ def argv
17
+ ARGV
78
18
  end
79
19
 
80
- if @parameters.has_key? :debug
81
- debug
82
- else
83
- system @command.join(' ')
20
+ # Parses the options passed via command line
21
+ def parse_argv
22
+ begin
23
+ cli argv,
24
+ # Cucumber options
25
+ '-t' => lambda{ |t| add_multiple(:tags, t) },
26
+ '-n --name' => lambda{ |n| @parameters[:name] = "--name #{n}" },
27
+ '-f --format' => ->(f){ @parameters[:format] = "--format #{f}" },
28
+ '-d --dry-run' => ->{ @parameters[:dry_run] = "--dry-run" },
29
+ '-v --verbose' => ->{ @parameters[:verbose] = "--verbose" },
30
+ '-s --strict' => ->{ @parameters[:strict] = "--strict" },
31
+ '-g --guess' => ->{ @parameters[:guess] = "--guess" },
32
+ '-x --expand' => ->{ @parameters[:expand] = "--expand" },
33
+
34
+ # All options below have been added for custom project but can be used for example
35
+ # Global options
36
+ '-e --environment' => ->(e){ @parameters[:environment] = "ENVIRONMENT=#{e}" },
37
+ '-l --loglevel' => ->(l){ @parameters[:log_level] = "LOG_LEVEL=#{l}" },
38
+ '-c --controller' => ->(c){ @parameters[:controller] = "CONTROLLER=#{c}" },
39
+ '-h --headless' => ->{ @parameters[:headless] = "HEADLESS=TRUE" },
40
+
41
+ # Database options
42
+ '--cleanup' => ->{ @parameters[:cleanup] = "CLEANUP=TRUE" },
43
+ '--no-cleanup' => ->{ @parameters[:cleanup] = "CLEANUP=FALSE" },
44
+ '--database' => ->{ @parameters[:database] = "DATABASE=TRUE" },
45
+ '--jenkins' => ->{ @parameters[:jenkins] = "JENKINS=TRUE" },
46
+
47
+ # Retry options
48
+ '--retries' => ->(r){ @parameters[:retries] = "RETRIES=#{r}" },
49
+ '--timeout' => ->(t){ @parameters[:timeout] = "TIMEOUT=#{t}" },
50
+
51
+ # Driver Options
52
+ '--screen' => ->(s){ split_parameters(s, :screen) },
53
+ '--position' => ->(p){ split_parameters(p, :position) },
54
+ '--screenwidth' => ->(w){ @parameters[:screen_width] = "SCREENWIDTH=#{w}" },
55
+ '--screenheight' => ->(h){ @parameters[:screen_height] = "SCREENHEIGHT=#{h}" },
56
+ '--xposition' => ->(x){ @parameters[:xposition] = "XPOSITION=#{x}" },
57
+ '--yposition' => ->(y){ @parameters[:yposition] = "YPOSITION=#{y}" },
58
+ '-H --highlight' => ->{ @parameters[:highlight] = "HIGHLIGHT=TRUE" },
59
+
60
+ # Debug
61
+ '--debug' => ->{ @parameters[:debug] = "DEBUG=TRUE" }
62
+ rescue
63
+ abort 'Error processing passed CLI arguments!'.red.underline
64
+ else
65
+ self
66
+ end
84
67
  end
85
- end
86
68
 
87
- # Outputs the debug information
88
- def debug
89
- puts 'DEBUG: Outputting ARGV passed'.yellow
90
- puts @args.inspect
91
- puts 'DEBUG: Outputting parameters created'.yellow
92
- puts @parameters.inspect
93
- puts 'DEBUG: Outputting command line created'.yellow
94
- puts @command.join(' ')
95
- end
69
+ # Builds the command line string
70
+ def build_command
71
+ check_for_task
72
+ check_for_parameters
73
+ set_runtime_defaults
74
+
75
+ unless @task.empty? && @parameters.empty?
76
+ @command.push 'bundle exec cucumber'
77
+ @command.push '--require features/'
78
+ @command.push task['feature_order'].join(' ')
79
+ @parameters.each { |k,v| @command.push(v) }
80
+ @command.push task['defaults'].join(' ')
81
+ end
96
82
 
97
- # Loads the config file
98
- #
99
- # @param [String] file the location of tasks.yml
100
- def load_config(file)
101
- begin
102
- return YAML.load_file(file)
103
- rescue Psych::SyntaxError
104
- abort 'Your tasks.yml did not parse as expected!'.red.underline
105
- rescue Exception
106
- abort 'Your tasks.yml file is missing!'.red.underline
83
+ if @parameters.has_key? :debug
84
+ debug
85
+ else
86
+ system @command.join(' ')
87
+ end
107
88
  end
108
- end
109
89
 
110
- # Checks for task in arguments
111
- def check_for_task
112
- @task = @args & @config.keys
113
- if @task.empty?
114
- abort 'ERROR: No task was passed to cukesparse!'.red.underline
115
- elsif @task.length > 1
116
- abort 'ERROR: Multiple tasks have been passed!'.red.underline
117
- else
118
- @task = @config[@task[0]]
90
+ # Outputs the debug information
91
+ def debug
92
+ puts 'DEBUG: Outputting ARGV passed'.yellow
93
+ puts argv.inspect
94
+ puts 'DEBUG: Outputting parsed config file'.yellow
95
+ puts @config.inspect
96
+ puts 'DEBUG: Outputting parameters created'.yellow
97
+ puts @parameters.inspect
98
+ puts 'DEBUG: Outputting command line created'.yellow
99
+ puts @command.join(' ')
100
+ end
101
+
102
+ # Loads the config file
103
+ def load_config
104
+ begin
105
+ @config = YAML.load_file(@config_file)
106
+ rescue Psych::SyntaxError
107
+ abort 'Your tasks.yml did not parse as expected!'.red.underline
108
+ rescue Exception
109
+ abort 'Your tasks.yml file is missing!'.red.underline
110
+ end
111
+
112
+ self
119
113
  end
120
- end
121
114
 
122
- # Checks parameters and returns boolean
123
- def check_for_parameters
124
- unless @parameters.any?
125
- puts 'WARN: No parameters passed to cukesparse'.yellow
115
+ # Checks for task in arguments
116
+ def check_for_task
117
+ any_task = argv & @config.keys
118
+ if any_task.empty?
119
+ abort 'ERROR: No task was passed to cukesparse!'.red.underline
120
+ elsif any_task.length > 1
121
+ abort 'ERROR: Multiple tasks have been passed!'.red.underline
122
+ else
123
+ @task = @config[any_task[0]]
124
+ end
126
125
  end
127
126
 
128
- set_runtime_defaults
129
- end
127
+ # Checks parameters and returns boolean
128
+ def check_for_parameters
129
+ unless @parameters.any?
130
+ puts 'WARN: No parameters passed to cukesparse'.yellow
131
+ end
132
+ end
130
133
 
131
- # Updates parameters based on config runtime defaults
132
- def set_runtime_defaults
133
- if @task.has_key?('runtime_defaults')
134
- @task['runtime_defaults'].each do |key, value|
135
- unless @parameters.has_key? key.to_sym
136
- @parameters[key.to_sym] = key.upcase + '=' + value.to_s
134
+ # Updates parameters based on config runtime defaults
135
+ def set_runtime_defaults
136
+ if @task.has_key?('runtime_defaults')
137
+ @task['runtime_defaults'].each do |key, value|
138
+ unless @parameters.has_key? key.to_sym
139
+ @parameters[key.to_sym] = key.upcase + '=' + value.to_s
140
+ end
137
141
  end
142
+ else
143
+ puts 'WARN: The task has no runtime defaults!'.yellow
138
144
  end
139
- else
140
- puts 'WARN: The task has no runtime defaults!'.yellow
141
145
  end
142
- end
143
146
 
144
- # Add multiple options to key
145
- #
146
- # @param [Symbol] key the key to store in options
147
- # @param [String] the arguments passed in for key
148
- def add_multiple(key, args)
149
- (@parameters[key] ||= []).push('--' + key.to_s + ' ' + args)
150
- end
151
-
152
- # Splits parameters passed
153
- #
154
- # @param [String] parameters the parameters passed
155
- # @param [Symbol] sym the symbol passed
156
- def split_parameters(parameters, sym)
157
- parameters = parameters.split(',')
158
- if parameters.length == 1
159
- abort "ERROR: You have not passed enough parameters in the #{sym.to_s} command line argument!".red.underline
160
- elsif parameters.length > 2
161
- abort "ERROR: You have passed to many parameters in the #{sym.to_s} command line argument!".red.underline
147
+ # Add multiple options to key
148
+ #
149
+ # @param [Symbol] key the key to store in options
150
+ # @param [String] val the arguments passed in for key
151
+ def add_multiple(key, val)
152
+ (@parameters[key] ||= []).push('--' + key.to_s + ' ' + val)
162
153
  end
163
154
 
164
- case sym
165
- when :screen
166
- @parameters[sym] = "SCREENWIDTH=#{parameters[0]} SCREENHEIGHT=#{parameters[1]}"
167
- when :position
168
- @parameters[sym] = "XPOSITION=#{parameters[0]} YPOSITION=#{parameters[1]}"
155
+ # Splits parameters passed
156
+ #
157
+ # @param [String] params the parameters passed
158
+ # @param [Symbol] sym the symbol passed
159
+ def split_parameters(params, sym)
160
+ params = params.split(',')
161
+ if params.length == 1
162
+ abort "ERROR: You have not passed enough parameters in the #{sym.to_s} command line argument!".red.underline
163
+ elsif params.length > 2
164
+ abort "ERROR: You have passed to many parameters in the #{sym.to_s} command line argument!".red.underline
165
+ end
166
+
167
+ case sym
168
+ when :screen
169
+ @parameters[sym] = "SCREENWIDTH=#{params[0]} SCREENHEIGHT=#{params[1]}"
170
+ when :position
171
+ @parameters[sym] = "XPOSITION=#{params[0]} YPOSITION=#{params[1]}"
172
+ end
169
173
  end
170
174
  end
175
+
176
+ # defaults
177
+ self.parameters = {}
178
+ self.task = {}
179
+ self.command = []
171
180
  end
181
+
182
+ Cukesparse.configure do |config|
183
+ config.config_file = 'config/tasks.yml'
184
+ end
@@ -6,24 +6,31 @@ require 'colored'
6
6
  require 'rspec'
7
7
 
8
8
  describe "cukesparse" do
9
- # Object
10
- context "when new" do
11
- before :all do
12
- # Clear arguments as rspec passes in script path
13
- ARGV = []
14
- @cukesparse = Cukesparse.new
15
- end
16
9
 
17
- it "should be an instance of cukesparse" do
18
- @cukesparse.should be_an_instance_of Cukesparse
10
+ before :each do
11
+ ARGV.clear
12
+ end
13
+
14
+ # Object
15
+ context "when called" do
16
+ it "should be an instance of Module" do
17
+ Cukesparse.should be_an_instance_of Module
19
18
  end
20
19
 
21
20
  it "returns true for empty opts parameter" do
22
- @cukesparse.parameters.should be_empty
21
+ Cukesparse.parameters.should be_empty
23
22
  end
24
23
 
25
24
  it "returns true for empty args parameter" do
26
- @cukesparse.args.should be_empty
25
+ Cukesparse.argv.should be_empty
26
+ end
27
+
28
+ it "returns true for empty task parameter" do
29
+ Cukesparse.task.should be_empty
30
+ end
31
+
32
+ it "returns true for empty command parameter" do
33
+ Cukesparse.command.should be_empty
27
34
  end
28
35
  end
29
36
 
@@ -31,671 +38,787 @@ describe "cukesparse" do
31
38
  context "when passed the -t parameter" do
32
39
  before :all do
33
40
  # Clear arguments as rspec passes in script path
34
- ARGV = ['test_task', '-t', 'test']
35
- @cukesparse = Cukesparse.new
36
- @cukesparse.parse_options
41
+ ARGV.push('test_task', '-t', 'test')
42
+ Cukesparse.parameters = {}
43
+ Cukesparse.parse_argv
37
44
  end
38
45
 
39
46
  it "should have a parameter of tags" do
40
- @cukesparse.parameters.should have_key :tags
47
+ Cukesparse.parameters.should have_key :tags
41
48
  end
42
49
 
43
50
  it "should have a tags parameter value of --tags test" do
44
- @cukesparse.parameters[:tags].should eql ['--tags test']
51
+ Cukesparse.parameters[:tags].should eql ['--tags test']
45
52
  end
46
53
  end
47
54
 
48
55
  context "when passed the -n parameter" do
49
56
  before :all do
50
57
  # Clear arguments as rspec passes in script path
51
- ARGV = ['test_task', '-n', 'name_test']
52
- @cukesparse = Cukesparse.new
53
- @cukesparse.parse_options
58
+ ARGV.push('test_task', '-n', 'name_test')
59
+ Cukesparse.parameters = {}
60
+ Cukesparse.parse_argv
54
61
  end
55
62
 
56
63
  it "should have a parameter of name" do
57
- @cukesparse.parameters.should have_key :name
64
+ Cukesparse.parameters.should have_key :name
58
65
  end
59
66
 
60
67
  it "should have a name parameter value of test" do
61
- @cukesparse.parameters[:name].should eql '--name name_test'
68
+ Cukesparse.parameters[:name].should eql '--name name_test'
62
69
  end
63
70
  end
64
71
 
65
72
  context "when passed the -name parameter" do
66
73
  before :all do
67
74
  # Clear arguments as rspec passes in script path
68
- ARGV = ['test_task', '--name', 'name_test']
69
- @cukesparse = Cukesparse.new
70
- @cukesparse.parse_options
75
+ ARGV.push('test_task', '--name', 'name_test')
76
+ Cukesparse.parameters = {}
77
+ Cukesparse.parse_argv
71
78
  end
72
79
 
73
80
  it "should have a parameter of name" do
74
- @cukesparse.parameters.should have_key :name
81
+ Cukesparse.parameters.should have_key :name
75
82
  end
76
83
 
77
84
  it "should have a name parameter value of test" do
78
- @cukesparse.parameters[:name].should eql '--name name_test'
85
+ Cukesparse.parameters[:name].should eql '--name name_test'
79
86
  end
80
87
  end
81
88
 
82
89
  context "when passed the -f parameter" do
83
90
  before :all do
84
91
  # Clear arguments as rspec passes in script path
85
- ARGV = ['test_task', '-f', 'pretty']
86
- @cukesparse = Cukesparse.new
87
- @cukesparse.parse_options
92
+ ARGV.push('test_task', '-f', 'pretty')
93
+ Cukesparse.parameters = {}
94
+ Cukesparse.parse_argv
88
95
  end
89
96
 
90
97
  it "should have a parameter of format" do
91
- @cukesparse.parameters.should have_key :format
98
+ Cukesparse.parameters.should have_key :format
92
99
  end
93
100
 
94
101
  it "should have a tags parameter value of test" do
95
- @cukesparse.parameters[:format].should eql '--format pretty'
102
+ Cukesparse.parameters[:format].should eql '--format pretty'
96
103
  end
97
104
  end
98
105
 
99
106
  context "when passed the --format parameter" do
100
107
  before :all do
101
108
  # Clear arguments as rspec passes in script path
102
- ARGV = ['test_task', '--format', 'pretty']
103
- @cukesparse = Cukesparse.new
104
- @cukesparse.parse_options
109
+ ARGV.push('test_task', '--format', 'pretty')
110
+ Cukesparse.parameters = {}
111
+ Cukesparse.parse_argv
105
112
  end
106
113
 
107
114
  it "should have a parameter of format" do
108
- @cukesparse.parameters.should have_key :format
115
+ Cukesparse.parameters.should have_key :format
109
116
  end
110
117
 
111
118
  it "should have a tags parameter value of test" do
112
- @cukesparse.parameters[:format].should eql '--format pretty'
119
+ Cukesparse.parameters[:format].should eql '--format pretty'
113
120
  end
114
121
  end
115
122
 
116
123
  context "when passed the -d parameter" do
117
124
  before :all do
118
125
  # Clear arguments as rspec passes in script path
119
- ARGV = ['test_task', '-d']
120
- @cukesparse = Cukesparse.new
121
- @cukesparse.parse_options
126
+ ARGV.push('test_task', '-d')
127
+ Cukesparse.parameters = {}
128
+ Cukesparse.parse_argv
122
129
  end
123
130
 
124
131
  it "should have a parameter of name" do
125
- @cukesparse.parameters.should have_key :dry_run
132
+ Cukesparse.parameters.should have_key :dry_run
126
133
  end
127
134
 
128
135
  it "should have a dry_run parameter value of --dry-run" do
129
- @cukesparse.parameters[:dry_run].should eql '--dry-run'
136
+ Cukesparse.parameters[:dry_run].should eql '--dry-run'
130
137
  end
131
138
  end
132
139
 
133
140
  context "when passed the --dry-run parameter" do
134
141
  before :all do
135
142
  # Clear arguments as rspec passes in script path
136
- ARGV = ['test_task', '--dry-run']
137
- @cukesparse = Cukesparse.new
138
- @cukesparse.parse_options
143
+ ARGV.push('test_task', '--dry-run')
144
+ Cukesparse.parameters = {}
145
+ Cukesparse.parse_argv
139
146
  end
140
147
 
141
148
  it "should have a parameter of dry_run" do
142
- @cukesparse.parameters.should have_key :dry_run
149
+ Cukesparse.parameters.should have_key :dry_run
143
150
  end
144
151
 
145
152
  it "should have a dry_run parameter value of --dry-run" do
146
- @cukesparse.parameters[:dry_run].should eql '--dry-run'
153
+ Cukesparse.parameters[:dry_run].should eql '--dry-run'
147
154
  end
148
155
  end
149
156
 
150
157
  context "when passed the -v parameter" do
151
158
  before :all do
152
159
  # Clear arguments as rspec passes in script path
153
- ARGV = ['test_task', '-v']
154
- @cukesparse = Cukesparse.new
155
- @cukesparse.parse_options
160
+ ARGV.push('test_task', '-v')
161
+ Cukesparse.parameters = {}
162
+ Cukesparse.parse_argv
156
163
  end
157
164
 
158
165
  it "should have a parameter of verbose" do
159
- @cukesparse.parameters.should have_key :verbose
166
+ Cukesparse.parameters.should have_key :verbose
160
167
  end
161
168
 
162
169
  it "should have a verbose parameter value of --verbose" do
163
- @cukesparse.parameters[:verbose].should eql '--verbose'
170
+ Cukesparse.parameters[:verbose].should eql '--verbose'
164
171
  end
165
172
  end
166
173
 
167
174
  context "when passed the --verbose parameter" do
168
175
  before :all do
169
176
  # Clear arguments as rspec passes in script path
170
- ARGV = ['test_task', '--verbose']
171
- @cukesparse = Cukesparse.new
172
- @cukesparse.parse_options
177
+ ARGV.push('test_task', '--verbose')
178
+ Cukesparse.parameters = {}
179
+ Cukesparse.parse_argv
173
180
  end
174
181
 
175
182
  it "should have a parameter of verbose" do
176
- @cukesparse.parameters.should have_key :verbose
183
+ Cukesparse.parameters.should have_key :verbose
177
184
  end
178
185
 
179
186
  it "should have a verbose parameter value of --verbose" do
180
- @cukesparse.parameters[:verbose].should eql '--verbose'
187
+ Cukesparse.parameters[:verbose].should eql '--verbose'
181
188
  end
182
189
  end
183
190
 
184
191
  context "when passed the -s parameter" do
185
192
  before :all do
186
193
  # Clear arguments as rspec passes in script path
187
- ARGV = ['test_task', '-s']
188
- @cukesparse = Cukesparse.new
189
- @cukesparse.parse_options
194
+ ARGV.push('test_task', '-s')
195
+ Cukesparse.parameters = {}
196
+ Cukesparse.parse_argv
190
197
  end
191
198
 
192
199
  it "should have a parameter of strict" do
193
- @cukesparse.parameters.should have_key :strict
200
+ Cukesparse.parameters.should have_key :strict
194
201
  end
195
202
 
196
203
  it "should have a strict parameter value of --strict" do
197
- @cukesparse.parameters[:strict].should eql '--strict'
204
+ Cukesparse.parameters[:strict].should eql '--strict'
198
205
  end
199
206
  end
200
207
 
201
208
  context "when passed the --strict parameter" do
202
209
  before :all do
203
210
  # Clear arguments as rspec passes in script path
204
- ARGV = ['test_task', '-s']
205
- @cukesparse = Cukesparse.new
206
- @cukesparse.parse_options
211
+ ARGV.push('test_task', '-s')
212
+ Cukesparse.parameters = {}
213
+ Cukesparse.parse_argv
207
214
  end
208
215
 
209
216
  it "should have a parameter of --strict" do
210
- @cukesparse.parameters.should have_key :strict
217
+ Cukesparse.parameters.should have_key :strict
211
218
  end
212
219
 
213
220
  it "should have a strict parameter value of --strict" do
214
- @cukesparse.parameters[:strict].should eql '--strict'
221
+ Cukesparse.parameters[:strict].should eql '--strict'
215
222
  end
216
223
  end
217
224
 
218
225
  context "when passed the -g parameter" do
219
226
  before :all do
220
227
  # Clear arguments as rspec passes in script path
221
- ARGV = ['test_task', '-g']
222
- @cukesparse = Cukesparse.new
223
- @cukesparse.parse_options
228
+ ARGV.push('test_task', '-g')
229
+ Cukesparse.parameters = {}
230
+ Cukesparse.parse_argv
224
231
  end
225
232
 
226
233
  it "should have a parameter of --guess" do
227
- @cukesparse.parameters.should have_key :guess
234
+ Cukesparse.parameters.should have_key :guess
228
235
  end
229
236
 
230
237
  it "should have a strict parameter value of --guess" do
231
- @cukesparse.parameters[:guess].should eql '--guess'
238
+ Cukesparse.parameters[:guess].should eql '--guess'
232
239
  end
233
240
  end
234
241
 
235
242
  context "when passed the --guess parameter" do
236
243
  before :all do
237
244
  # Clear arguments as rspec passes in script path
238
- ARGV = ['test_task', '--guess']
239
- @cukesparse = Cukesparse.new
240
- @cukesparse.parse_options
245
+ ARGV.push('test_task', '--guess')
246
+ Cukesparse.parameters = {}
247
+ Cukesparse.parse_argv
241
248
  end
242
249
 
243
250
  it "should have a parameter of --guess" do
244
- @cukesparse.parameters.should have_key :guess
251
+ Cukesparse.parameters.should have_key :guess
245
252
  end
246
253
 
247
254
  it "should have a strict parameter value of --guess" do
248
- @cukesparse.parameters[:guess].should eql '--guess'
255
+ Cukesparse.parameters[:guess].should eql '--guess'
249
256
  end
250
257
  end
251
258
 
252
259
  context "when passed the -x parameter" do
253
260
  before :all do
254
261
  # Clear arguments as rspec passes in script path
255
- ARGV = ['test_task', '-x']
256
- @cukesparse = Cukesparse.new
257
- @cukesparse.parse_options
262
+ ARGV.push('test_task', '-x')
263
+ Cukesparse.parameters = {}
264
+ Cukesparse.parse_argv
258
265
  end
259
266
 
260
267
  it "should have a parameter of --expand" do
261
- @cukesparse.parameters.should have_key :expand
268
+ Cukesparse.parameters.should have_key :expand
262
269
  end
263
270
 
264
271
  it "should have a strict parameter value of --expand" do
265
- @cukesparse.parameters[:expand].should eql '--expand'
272
+ Cukesparse.parameters[:expand].should eql '--expand'
266
273
  end
267
274
  end
268
275
 
269
276
  context "when passed the --expand parameter" do
270
277
  before :all do
271
278
  # Clear arguments as rspec passes in script path
272
- ARGV = ['test_task', '--expand']
273
- @cukesparse = Cukesparse.new
274
- @cukesparse.parse_options
279
+ ARGV.push('test_task', '--expand')
280
+ Cukesparse.parameters = {}
281
+ Cukesparse.parse_argv
275
282
  end
276
283
 
277
284
  it "should have a parameter of --expand" do
278
- @cukesparse.parameters.should have_key :expand
285
+ Cukesparse.parameters.should have_key :expand
279
286
  end
280
287
 
281
288
  it "should have a strict parameter value of --expand" do
282
- @cukesparse.parameters[:expand].should eql '--expand'
289
+ Cukesparse.parameters[:expand].should eql '--expand'
283
290
  end
284
291
  end
285
292
 
286
293
  context "when passed the -e parameter" do
287
294
  before :all do
288
295
  # Clear arguments as rspec passes in script path
289
- ARGV = ['test_task', '-e', 'test_environment']
290
- @cukesparse = Cukesparse.new
291
- @cukesparse.parse_options
296
+ ARGV.push('test_task', '-e', 'test_environment')
297
+ Cukesparse.parameters = {}
298
+ Cukesparse.parse_argv
292
299
  end
293
300
 
294
301
  it "should have a parameter of environment" do
295
- @cukesparse.parameters.should have_key :environment
302
+ Cukesparse.parameters.should have_key :environment
296
303
  end
297
304
 
298
305
  it "should have a environment parameter value of ENVIRONMENT=test_environment" do
299
- @cukesparse.parameters[:environment].should eql 'ENVIRONMENT=test_environment'
306
+ Cukesparse.parameters[:environment].should eql 'ENVIRONMENT=test_environment'
300
307
  end
301
308
  end
302
309
 
303
310
  context "when passed the --environment parameter" do
304
311
  before :all do
305
312
  # Clear arguments as rspec passes in script path
306
- ARGV = ['test_task', '--environment', 'test_environment']
307
- @cukesparse = Cukesparse.new
308
- @cukesparse.parse_options
313
+ ARGV.push('test_task', '--environment', 'test_environment')
314
+ Cukesparse.parameters = {}
315
+ Cukesparse.parse_argv
309
316
  end
310
317
 
311
318
  it "should have a parameter of environment" do
312
- @cukesparse.parameters.should have_key :environment
319
+ Cukesparse.parameters.should have_key :environment
313
320
  end
314
321
 
315
322
  it "should have a environment parameter value of ENVIRONMENT=test_environment" do
316
- @cukesparse.parameters[:environment].should eql 'ENVIRONMENT=test_environment'
323
+ Cukesparse.parameters[:environment].should eql 'ENVIRONMENT=test_environment'
317
324
  end
318
325
  end
319
326
 
320
327
  context "when passed the -l parameter" do
321
328
  before :all do
322
329
  # Clear arguments as rspec passes in script path
323
- ARGV = ['test_task', '-l', 'debug']
324
- @cukesparse = Cukesparse.new
325
- @cukesparse.parse_options
330
+ ARGV.push('test_task', '-l', 'debug')
331
+ Cukesparse.parameters = {}
332
+ Cukesparse.parse_argv
326
333
  end
327
334
 
328
335
  it "should have a parameter of loglevel" do
329
- @cukesparse.parameters.should have_key :log_level
336
+ Cukesparse.parameters.should have_key :log_level
330
337
  end
331
338
 
332
339
  it "should have a loglevel parameter value of LOG_LEVEL=debug" do
333
- @cukesparse.parameters[:log_level].should eql 'LOG_LEVEL=debug'
340
+ Cukesparse.parameters[:log_level].should eql 'LOG_LEVEL=debug'
334
341
  end
335
342
  end
336
343
 
337
344
  context "when passed the --loglevel parameter" do
338
345
  before :all do
339
346
  # Clear arguments as rspec passes in script path
340
- ARGV = ['test_task', '--loglevel', 'debug']
341
- @cukesparse = Cukesparse.new
342
- @cukesparse.parse_options
347
+ ARGV.push('test_task', '--loglevel', 'debug')
348
+ Cukesparse.parameters = {}
349
+ Cukesparse.parse_argv
343
350
  end
344
351
 
345
352
  it "should have a parameter of loglevel" do
346
- @cukesparse.parameters.should have_key :log_level
353
+ Cukesparse.parameters.should have_key :log_level
347
354
  end
348
355
 
349
356
  it "should have a loglevel parameter value of LOG_LEVEL=debug" do
350
- @cukesparse.parameters[:log_level].should eql 'LOG_LEVEL=debug'
357
+ Cukesparse.parameters[:log_level].should eql 'LOG_LEVEL=debug'
351
358
  end
352
359
  end
353
360
 
354
361
  context "when passed the -c parameter" do
355
362
  before :all do
356
363
  # Clear arguments as rspec passes in script path
357
- ARGV = ['test_task', '-c', 'browser']
358
- @cukesparse = Cukesparse.new
359
- @cukesparse.parse_options
364
+ ARGV.push('test_task', '-c', 'browser')
365
+ Cukesparse.parameters = {}
366
+ Cukesparse.parse_argv
360
367
  end
361
368
 
362
369
  it "should have a parameter of controller" do
363
- @cukesparse.parameters.should have_key :controller
370
+ Cukesparse.parameters.should have_key :controller
364
371
  end
365
372
 
366
373
  it "should have a controller parameter value of CONTROLLER=browser" do
367
- @cukesparse.parameters[:controller].should eql 'CONTROLLER=browser'
374
+ Cukesparse.parameters[:controller].should eql 'CONTROLLER=browser'
368
375
  end
369
376
  end
370
377
 
371
378
  context "when passed the --controller parameter" do
372
379
  before :all do
373
380
  # Clear arguments as rspec passes in script path
374
- ARGV = ['test_task', '--controller', 'browser']
375
- @cukesparse = Cukesparse.new
376
- @cukesparse.parse_options
381
+ ARGV.push('test_task', '--controller', 'browser')
382
+ Cukesparse.parameters = {}
383
+ Cukesparse.parse_argv
377
384
  end
378
385
 
379
386
  it "should have a parameter of controller" do
380
- @cukesparse.parameters.should have_key :controller
387
+ Cukesparse.parameters.should have_key :controller
381
388
  end
382
389
 
383
390
  it "should have a controller parameter value of CONTROLLER=browser" do
384
- @cukesparse.parameters[:controller].should eql 'CONTROLLER=browser'
391
+ Cukesparse.parameters[:controller].should eql 'CONTROLLER=browser'
385
392
  end
386
393
  end
387
394
 
388
395
  context "when passed the -h parameter" do
389
396
  before :all do
390
397
  # Clear arguments as rspec passes in script path
391
- ARGV = ['test_task', '-h']
392
- @cukesparse = Cukesparse.new
393
- @cukesparse.parse_options
398
+ ARGV.push('test_task', '-h')
399
+ Cukesparse.parameters = {}
400
+ Cukesparse.parse_argv
394
401
  end
395
402
 
396
403
  it "should have a parameter of headless" do
397
- @cukesparse.parameters.should have_key :headless
404
+ Cukesparse.parameters.should have_key :headless
398
405
  end
399
406
 
400
407
  it "should have a headless parameter value of HEADLESS=TRUE" do
401
- @cukesparse.parameters[:headless].should eql 'HEADLESS=TRUE'
408
+ Cukesparse.parameters[:headless].should eql 'HEADLESS=TRUE'
402
409
  end
403
410
  end
404
411
 
405
412
  context "when passed the --headless parameter" do
406
413
  before :all do
407
414
  # Clear arguments as rspec passes in script path
408
- ARGV = ['test_task', '--headless']
409
- @cukesparse = Cukesparse.new
410
- @cukesparse.parse_options
415
+ ARGV.push('test_task', '--headless')
416
+ Cukesparse.parameters = {}
417
+ Cukesparse.parse_argv
411
418
  end
412
419
 
413
420
  it "should have a parameter of headless" do
414
- @cukesparse.parameters.should have_key :headless
421
+ Cukesparse.parameters.should have_key :headless
415
422
  end
416
423
 
417
424
  it "should have a headless parameter value of HEADLESS=TRUE" do
418
- @cukesparse.parameters[:headless].should eql 'HEADLESS=TRUE'
425
+ Cukesparse.parameters[:headless].should eql 'HEADLESS=TRUE'
419
426
  end
420
427
  end
421
428
 
422
429
  context "when passed the --cleanup parameter" do
423
430
  before :all do
424
431
  # Clear arguments as rspec passes in script path
425
- ARGV = ['test_task', '--cleanup']
426
- @cukesparse = Cukesparse.new
427
- @cukesparse.parse_options
432
+ ARGV.push('test_task', '--cleanup')
433
+ Cukesparse.parameters = {}
434
+ Cukesparse.parse_argv
428
435
  end
429
436
 
430
437
  it "should have a parameter of cleanup" do
431
- @cukesparse.parameters.should have_key :cleanup
438
+ Cukesparse.parameters.should have_key :cleanup
432
439
  end
433
440
 
434
441
  it "should have a cleanup parameter value of CLEANUP=TRUE" do
435
- @cukesparse.parameters[:cleanup].should eql 'CLEANUP=TRUE'
442
+ Cukesparse.parameters[:cleanup].should eql 'CLEANUP=TRUE'
436
443
  end
437
444
  end
438
445
 
439
446
  context "when passed the --no-cleanup parameter" do
440
447
  before :all do
441
448
  # Clear arguments as rspec passes in script path
442
- ARGV = ['test_task', '--no-cleanup']
443
- @cukesparse = Cukesparse.new
444
- @cukesparse.parse_options
449
+ ARGV.push('test_task', '--no-cleanup')
450
+ Cukesparse.parameters = {}
451
+ Cukesparse.parse_argv
445
452
  end
446
453
 
447
454
  it "should have a parameter of cleanup" do
448
- @cukesparse.parameters.should have_key :cleanup
455
+ Cukesparse.parameters.should have_key :cleanup
449
456
  end
450
457
 
451
458
  it "should have a cleanup parameter value of CLEANUP=FALSE" do
452
- @cukesparse.parameters[:cleanup].should eql 'CLEANUP=FALSE'
459
+ Cukesparse.parameters[:cleanup].should eql 'CLEANUP=FALSE'
453
460
  end
454
461
  end
455
462
 
456
463
  context "when passed the --database parameter" do
457
464
  before :all do
458
465
  # Clear arguments as rspec passes in script path
459
- ARGV = ['test_task', '--database']
460
- @cukesparse = Cukesparse.new
461
- @cukesparse.parse_options
466
+ ARGV.push('test_task', '--database')
467
+ Cukesparse.parameters = {}
468
+ Cukesparse.parse_argv
462
469
  end
463
470
 
464
471
  it "should have a parameter of database" do
465
- @cukesparse.parameters.should have_key :database
472
+ Cukesparse.parameters.should have_key :database
466
473
  end
467
474
 
468
475
  it "should have a database parameter value of DATABASE=TRUE" do
469
- @cukesparse.parameters[:database].should eql 'DATABASE=TRUE'
476
+ Cukesparse.parameters[:database].should eql 'DATABASE=TRUE'
470
477
  end
471
478
  end
472
479
 
473
480
  context "when passed the --jenkins parameter" do
474
481
  before :all do
475
482
  # Clear arguments as rspec passes in script path
476
- ARGV = ['test_task', '--jenkins']
477
- @cukesparse = Cukesparse.new
478
- @cukesparse.parse_options
483
+ ARGV.push('test_task', '--jenkins')
484
+ Cukesparse.parameters = {}
485
+ Cukesparse.parse_argv
479
486
  end
480
487
 
481
488
  it "should have a parameter of jenkins" do
482
- @cukesparse.parameters.should have_key :jenkins
489
+ Cukesparse.parameters.should have_key :jenkins
483
490
  end
484
491
 
485
492
  it "should have a jenkins parameter value of JENKINS=TRUE" do
486
- @cukesparse.parameters[:jenkins].should eql 'JENKINS=TRUE'
493
+ Cukesparse.parameters[:jenkins].should eql 'JENKINS=TRUE'
487
494
  end
488
495
  end
489
496
 
490
497
  context "when passed the --retries parameter" do
491
498
  before :all do
492
499
  # Clear arguments as rspec passes in script path
493
- ARGV = ['test_task', '--retries', '5']
494
- @cukesparse = Cukesparse.new
495
- @cukesparse.parse_options
500
+ ARGV.push('test_task', '--retries', '5')
501
+ Cukesparse.parameters = {}
502
+ Cukesparse.parse_argv
496
503
  end
497
504
 
498
505
  it "should have a parameter of retries" do
499
- @cukesparse.parameters.should have_key :retries
506
+ Cukesparse.parameters.should have_key :retries
500
507
  end
501
508
 
502
509
  it "should have a retries parameter value of RETRIES=5" do
503
- @cukesparse.parameters[:retries].should eql 'RETRIES=5'
510
+ Cukesparse.parameters[:retries].should eql 'RETRIES=5'
504
511
  end
505
512
  end
506
513
 
507
514
  context "when passed the --timeout parameter" do
508
515
  before :all do
509
516
  # Clear arguments as rspec passes in script path
510
- ARGV = ['test_task', '--timeout', '10']
511
- @cukesparse = Cukesparse.new
512
- @cukesparse.parse_options
517
+ ARGV.push('test_task', '--timeout', '10')
518
+ Cukesparse.parameters = {}
519
+ Cukesparse.parse_argv
513
520
  end
514
521
 
515
522
  it "should have a parameter of timeout" do
516
- @cukesparse.parameters.should have_key :timeout
523
+ Cukesparse.parameters.should have_key :timeout
517
524
  end
518
525
 
519
526
  it "should have a timeout parameter value of TIMEOUT=10" do
520
- @cukesparse.parameters[:timeout].should eql 'TIMEOUT=10'
527
+ Cukesparse.parameters[:timeout].should eql 'TIMEOUT=10'
521
528
  end
522
529
  end
523
530
 
524
531
  context "when passed the --screen parameter" do
525
532
  before :all do
526
533
  # Clear arguments as rspec passes in script path
527
- ARGV = ['test_task', '--screen', '1280,1024']
528
- @cukesparse = Cukesparse.new
529
- @cukesparse.parse_options
534
+ ARGV.push('test_task', '--screen', '1280,1024')
535
+ Cukesparse.parameters = {}
536
+ Cukesparse.parse_argv
530
537
  end
531
538
 
532
539
  it "should have a parameter of screen" do
533
- @cukesparse.parameters.should have_key :screen
540
+ Cukesparse.parameters.should have_key :screen
534
541
  end
535
542
 
536
543
  it "should have a screen parameter value of SCREENWIDTH=1280 SCREENHEIGHT=1024" do
537
- @cukesparse.parameters[:screen].should eql 'SCREENWIDTH=1280 SCREENHEIGHT=1024'
544
+ Cukesparse.parameters[:screen].should eql 'SCREENWIDTH=1280 SCREENHEIGHT=1024'
538
545
  end
539
546
  end
540
547
 
541
548
  context "when passed the --position parameter" do
542
549
  before :all do
543
550
  # Clear arguments as rspec passes in script path
544
- ARGV = ['test_task', '--position', '0,0']
545
- @cukesparse = Cukesparse.new
546
- @cukesparse.parse_options
551
+ ARGV.push('test_task', '--position', '0,0')
552
+ Cukesparse.parameters = {}
553
+ Cukesparse.parse_argv
547
554
  end
548
555
 
549
556
  it "should have a parameter of position" do
550
- @cukesparse.parameters.should have_key :position
557
+ Cukesparse.parameters.should have_key :position
551
558
  end
552
559
 
553
560
  it "should have a position parameter value of XPOSITION=0 YPOSITION=0" do
554
- @cukesparse.parameters[:position].should eql 'XPOSITION=0 YPOSITION=0'
561
+ Cukesparse.parameters[:position].should eql 'XPOSITION=0 YPOSITION=0'
555
562
  end
556
563
  end
557
564
 
558
565
  context "when passed the --screenwidth parameter" do
559
566
  before :all do
560
567
  # Clear arguments as rspec passes in script path
561
- ARGV = ['test_task', '--screenwidth', '1280']
562
- @cukesparse = Cukesparse.new
563
- @cukesparse.parse_options
568
+ ARGV.push('test_task', '--screenwidth', '1280')
569
+ Cukesparse.parameters = {}
570
+ Cukesparse.parse_argv
564
571
  end
565
572
 
566
573
  it "should have a parameter of screenwidth" do
567
- @cukesparse.parameters.should have_key :screen_width
574
+ Cukesparse.parameters.should have_key :screen_width
568
575
  end
569
576
 
570
577
  it "should have a screenwidth parameter value of SCREENWIDTH=1280" do
571
- @cukesparse.parameters[:screen_width].should eql 'SCREENWIDTH=1280'
578
+ Cukesparse.parameters[:screen_width].should eql 'SCREENWIDTH=1280'
572
579
  end
573
580
  end
574
581
 
575
582
  context "when passed the --screenheight parameter" do
576
583
  before :all do
577
584
  # Clear arguments as rspec passes in script path
578
- ARGV = ['test_task', '--screenheight', '1024']
579
- @cukesparse = Cukesparse.new
580
- @cukesparse.parse_options
585
+ ARGV.push('test_task', '--screenheight', '1024')
586
+ Cukesparse.parameters = {}
587
+ Cukesparse.parse_argv
581
588
  end
582
589
 
583
590
  it "should have a parameter of screenheight" do
584
- @cukesparse.parameters.should have_key :screen_height
591
+ Cukesparse.parameters.should have_key :screen_height
585
592
  end
586
593
 
587
594
  it "should have a screenheight parameter value of SCREENHEIGHT=1024" do
588
- @cukesparse.parameters[:screen_height].should eql 'SCREENHEIGHT=1024'
595
+ Cukesparse.parameters[:screen_height].should eql 'SCREENHEIGHT=1024'
589
596
  end
590
597
  end
591
598
 
592
599
  context "when passed the --xposition parameter" do
593
600
  before :all do
594
601
  # Clear arguments as rspec passes in script path
595
- ARGV = ['test_task', '--xposition', '100']
596
- @cukesparse = Cukesparse.new
597
- @cukesparse.parse_options
602
+ ARGV.push('test_task', '--xposition', '100')
603
+ Cukesparse.parameters = {}
604
+ Cukesparse.parse_argv
598
605
  end
599
606
 
600
607
  it "should have a parameter of xposition" do
601
- @cukesparse.parameters.should have_key :xposition
608
+ Cukesparse.parameters.should have_key :xposition
602
609
  end
603
610
 
604
611
  it "should have a xposition parameter value of XPOSITION=100" do
605
- @cukesparse.parameters[:xposition].should eql 'XPOSITION=100'
612
+ Cukesparse.parameters[:xposition].should eql 'XPOSITION=100'
606
613
  end
607
614
  end
608
615
 
609
616
  context "when passed the --yposition parameter" do
610
617
  before :all do
611
618
  # Clear arguments as rspec passes in script path
612
- ARGV = ['test_task', '--yposition', '100']
613
- @cukesparse = Cukesparse.new
614
- @cukesparse.parse_options
619
+ ARGV.push('test_task', '--yposition', '100')
620
+ Cukesparse.parameters = {}
621
+ Cukesparse.parse_argv
615
622
  end
616
623
 
617
624
  it "should have a parameter of yposition" do
618
- @cukesparse.parameters.should have_key :yposition
625
+ Cukesparse.parameters.should have_key :yposition
619
626
  end
620
627
 
621
628
  it "should have a yposition parameter value of YPOSITION=100" do
622
- @cukesparse.parameters[:yposition].should eql 'YPOSITION=100'
629
+ Cukesparse.parameters[:yposition].should eql 'YPOSITION=100'
623
630
  end
624
631
  end
625
632
 
626
633
  context "when passed the -H parameter" do
627
634
  before :all do
628
635
  # Clear arguments as rspec passes in script path
629
- ARGV = ['test_task', '-H']
630
- @cukesparse = Cukesparse.new
631
- @cukesparse.parse_options
636
+ ARGV.push('test_task', '-H')
637
+ Cukesparse.parameters = {}
638
+ Cukesparse.parse_argv
632
639
  end
633
640
 
634
641
  it "should have a parameter of highlight" do
635
- @cukesparse.parameters.should have_key :highlight
642
+ Cukesparse.parameters.should have_key :highlight
636
643
  end
637
644
 
638
645
  it "should have a highlight parameter value of HIGHLIGHT=TRUE" do
639
- @cukesparse.parameters[:highlight].should eql 'HIGHLIGHT=TRUE'
646
+ Cukesparse.parameters[:highlight].should eql 'HIGHLIGHT=TRUE'
640
647
  end
641
648
  end
642
649
 
643
650
  context "when passed the --highlight parameter" do
644
651
  before :all do
645
652
  # Clear arguments as rspec passes in script path
646
- ARGV = ['test_task', '--highlight']
647
- @cukesparse = Cukesparse.new
648
- @cukesparse.parse_options
653
+ ARGV.push('test_task', '--highlight')
654
+ Cukesparse.parameters = {}
655
+ Cukesparse.parse_argv
649
656
  end
650
657
 
651
658
  it "should have a parameter of highlight" do
652
- @cukesparse.parameters.should have_key :highlight
659
+ Cukesparse.parameters.should have_key :highlight
653
660
  end
654
661
 
655
662
  it "should have a highlight parameter value of HIGHLIGHT=TRUE" do
656
- @cukesparse.parameters[:highlight].should eql 'HIGHLIGHT=TRUE'
663
+ Cukesparse.parameters[:highlight].should eql 'HIGHLIGHT=TRUE'
657
664
  end
658
665
  end
659
666
 
660
667
  context "when passed the --debug parameter" do
661
668
  before :all do
662
669
  # Clear arguments as rspec passes in script path
663
- ARGV = ['test_task', '--debug']
664
- @cukesparse = Cukesparse.new
665
- @cukesparse.parse_options
670
+ ARGV.push('test_task', '--debug')
671
+ Cukesparse.parameters = {}
672
+ Cukesparse.parse_argv
666
673
  end
667
674
 
668
675
  it "should have a parameter of debug" do
669
- @cukesparse.parameters.should have_key :debug
676
+ Cukesparse.parameters.should have_key :debug
670
677
  end
671
678
 
672
679
  it "should have a debug parameter value of DEBUG=TRUE" do
673
- @cukesparse.parameters[:debug].should eql 'DEBUG=TRUE'
680
+ Cukesparse.parameters[:debug].should eql 'DEBUG=TRUE'
681
+ end
682
+ end
683
+
684
+ # check_for_tasks
685
+ context "when task is defined the @task instance variable will return a hash" do
686
+ it "will set the task in @task" do
687
+ ARGV.push('test_task')
688
+ Cukesparse.configure {|c| c.config_file = './spec/spec_files/valid_tasks.yml'}
689
+ Cukesparse.load_config
690
+ Cukesparse.check_for_task
691
+ Cukesparse.task.should be_an_instance_of Hash
674
692
  end
675
693
  end
676
694
 
677
- # Default Parameters
695
+ # default_parameters
678
696
  context "when running the test task runtime default vars should be set when no arguments passed" do
679
697
  before :all do
680
698
  # Clear arguments as rspec passes in script path
681
699
  # Adding test tag to prevent raise
682
- ARGV = ['test_task', '-t', 'test']
683
- @cukesparse = Cukesparse.new
684
- @cukesparse.parse_options
685
- @cukesparse.check_for_task
686
- @cukesparse.check_for_parameters
700
+ ARGV.push('test_task', '-t', 'test')
701
+ Cukesparse.parameters = {}
702
+ Cukesparse.configure {|c| c.config_file = './spec/spec_files/valid_tasks.yml'}
703
+ Cukesparse.load_config.parse_argv
704
+ Cukesparse.check_for_task
705
+ Cukesparse.check_for_parameters
706
+ Cukesparse.set_runtime_defaults
687
707
  end
688
708
 
689
709
  it "should have runtime default parameters" do
690
- @cukesparse.parameters.should have_key :environment
691
- @cukesparse.parameters.should have_key :log_level
692
- @cukesparse.parameters.should have_key :format
710
+ Cukesparse.parameters.should have_key :environment
711
+ Cukesparse.parameters.should have_key :log_level
712
+ Cukesparse.parameters.should have_key :format
693
713
  end
694
714
 
695
715
  it "should have the expected default runtime parameter values" do
696
- @cukesparse.parameters[:environment].should eql 'ENVIRONMENT=release'
697
- @cukesparse.parameters[:log_level].should eql 'LOG_LEVEL=debug'
698
- @cukesparse.parameters[:format].should eql 'FORMAT=pretty'
716
+ Cukesparse.parameters[:environment].should eql 'ENVIRONMENT=release'
717
+ Cukesparse.parameters[:log_level].should eql 'LOG_LEVEL=debug'
718
+ Cukesparse.parameters[:format].should eql 'FORMAT=pretty'
719
+ end
720
+ end
721
+
722
+ # add_multiple
723
+ context "when add_multiple is called" do
724
+ it "it will add a key to parameters with the correct array value" do
725
+ Cukesparse.add_multiple(:test, 'abc')
726
+ Cukesparse.parameters.should have_key(:test)
727
+ Cukesparse.parameters[:test].should eql ['--test abc']
728
+ end
729
+ end
730
+
731
+ # split_parameters
732
+ context "when split parameters sends :screen symbol with arguments" do
733
+ it "will return set a parameters screen key and value" do
734
+ Cukesparse.split_parameters('1024,1280', :screen)
735
+ Cukesparse.parameters.should have_key(:screen)
736
+ Cukesparse.parameters[:screen].should eql "SCREENWIDTH=1024 SCREENHEIGHT=1280"
737
+ end
738
+ end
739
+
740
+ context "when split parameters sends :position symbol with arguments" do
741
+ it "will return set a parameters screen key and value" do
742
+ Cukesparse.split_parameters('0,100', :position)
743
+ Cukesparse.parameters.should have_key(:position)
744
+ Cukesparse.parameters[:position].should eql "XPOSITION=0 YPOSITION=100"
745
+ end
746
+ end
747
+
748
+ # CLI
749
+ context "when CLI is run with incorrect ARGV array" do
750
+ it "will return an error if arguments are nil" do
751
+ ARGV.push(nil)
752
+ Cukesparse.should_receive("abort").with("\e[4;31;49mError processing passed CLI arguments!\e[0m")
753
+ Cukesparse.parse_argv
754
+ end
755
+ end
756
+
757
+ context "when CLI is run with incorrect task file" do
758
+ it "will return an error if the task file fails to parse" do
759
+ Cukesparse.configure {|c| c.config_file = './spec/spec_files/invalid_tasks.yml'}
760
+ Cukesparse.should_receive("abort").with("\e[4;31;49mYour tasks.yml did not parse as expected!\e[0m")
761
+ Cukesparse.load_config
762
+ end
763
+ end
764
+
765
+ context "when CLI is run with task file missing" do
766
+ it "will return an error if the task file is missing" do
767
+ Cukesparse.configure {|c| c.config_file = './spec/spec_files/missing_tasks.yml'}
768
+ Cukesparse.should_receive("abort").with("\e[4;31;49mYour tasks.yml file is missing!\e[0m")
769
+ Cukesparse.load_config
770
+ end
771
+ end
772
+
773
+ context "when CLI is run with no task defined" do
774
+ it "will return an error if no task is provided" do
775
+ ARGV.push('incorrect_task')
776
+ Cukesparse.config = {}
777
+ Cukesparse.should_receive("abort").with("\e[4;31;49mERROR: No task was passed to cukesparse!\e[0m")
778
+ Cukesparse.check_for_task
779
+ end
780
+ end
781
+
782
+ context "when CLI is run with multiple tasks defined" do
783
+ it "will return an error if multiple tasks are provided" do
784
+ ARGV.push('test_task', 'test_task1')
785
+ Cukesparse.configure {|c| c.config_file = './spec/spec_files/valid_tasks.yml'}
786
+ Cukesparse.load_config
787
+ Cukesparse.should_receive("abort").with("\e[4;31;49mERROR: Multiple tasks have been passed!\e[0m")
788
+ Cukesparse.check_for_task
789
+ end
790
+ end
791
+
792
+ context "when CLI is run with no paramaters defined" do
793
+ it "will return an warning if no parameters are provided" do
794
+ Cukesparse.instance_variable_set(:@parameters, {})
795
+ Cukesparse.should_receive("puts").with("\e[0;33;49mWARN: No parameters passed to cukesparse\e[0m")
796
+ Cukesparse.check_for_parameters
797
+ end
798
+ end
799
+
800
+ context "when CLI is run with no runtime_defaults defined" do
801
+ it "will return a warning if no runtime_defaults are provided" do
802
+ ARGV.push('no_runtime_defaults')
803
+ Cukesparse.configure {|c| c.config_file = './spec/spec_files/valid_tasks.yml'}
804
+ Cukesparse.load_config
805
+ Cukesparse.check_for_task
806
+ Cukesparse.should_receive("puts").with("\e[0;33;49mWARN: The task has no runtime defaults!\e[0m")
807
+ Cukesparse.set_runtime_defaults
808
+ end
809
+ end
810
+
811
+ context "when CLI is run with and split paramters which sends one argument" do
812
+ it "will return a error" do
813
+ Cukesparse.should_receive("abort").with("\e[4;31;49mERROR: You have not passed enough parameters in the test command line argument!\e[0m")
814
+ Cukesparse.split_parameters('1024', :test)
815
+ end
816
+ end
817
+
818
+ context "when CLI is run with and split paramters which over two argument" do
819
+ it "will return a error" do
820
+ Cukesparse.should_receive("abort").with("\e[4;31;49mERROR: You have passed to many parameters in the test command line argument!\e[0m")
821
+ Cukesparse.split_parameters('1024,1280,16', :test)
699
822
  end
700
823
  end
701
824
  end