cuke_commander 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +22 -0
- data/.simplecov +11 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +50 -0
- data/Rakefile +45 -0
- data/cuke_commander.gemspec +26 -0
- data/features/command_line_format.feature +179 -0
- data/features/cucumber_options.feature +46 -0
- data/features/generate_command_line.feature +11 -0
- data/features/step_definitions/action_steps.rb +156 -0
- data/features/step_definitions/setup_steps.rb +3 -0
- data/features/step_definitions/verification_steps.rb +19 -0
- data/features/support/env.rb +4 -0
- data/lib/cuke_commander.rb +10 -0
- data/lib/cuke_commander/cl_generator.rb +208 -0
- data/lib/cuke_commander/version.rb +5 -0
- data/spec/cl_generator_spec.rb +249 -0
- data/spec/cuke_commander_spec.rb +17 -0
- data/spec/spec_helper.rb +5 -0
- metadata +164 -0
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/.simplecov
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Grange Insurance
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# CukeCommander
|
2
|
+
|
3
|
+
The cuke_commander gem provides an easy and programmatic way to build a command line for running Cucumber.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'cuke_commander'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install cuke_commander
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
require 'cuke_commander'
|
22
|
+
|
23
|
+
# Choose your Cucumber options
|
24
|
+
cucumber_options = {tags: ['@tag1', '@tag2,@tag3'],
|
25
|
+
formatters: {json: 'json_output.txt',
|
26
|
+
pretty: ''},
|
27
|
+
options: ['-r features']}
|
28
|
+
|
29
|
+
# Use the generator to create an appropriate Cucumber command line
|
30
|
+
clg = CukeCommander::CLGenerator.new
|
31
|
+
command_line = clg.generate_command_line(cucumber_options)
|
32
|
+
|
33
|
+
puts command_line
|
34
|
+
# This will produce something along the lines of
|
35
|
+
# cucumber -t @tag1 -t @tag2,@tag3 -f json -o json_output.txt -f pretty -r features
|
36
|
+
|
37
|
+
# Use the command line to kick off Cucumber
|
38
|
+
system(command_line)
|
39
|
+
|
40
|
+
Simple!
|
41
|
+
|
42
|
+
(see documentation for all implemented Cucumber options)
|
43
|
+
|
44
|
+
## Contributing
|
45
|
+
|
46
|
+
1. Fork it ( https://github.com/[my-github-username]/cuke_commander/fork )
|
47
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
48
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
49
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
50
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require 'cucumber/rake/task'
|
3
|
+
require 'rspec/core/rake_task'
|
4
|
+
|
5
|
+
|
6
|
+
def set_cucumber_options(options)
|
7
|
+
ENV['CUCUMBER_OPTS'] = options
|
8
|
+
end
|
9
|
+
|
10
|
+
def combine_options(set_1, set_2)
|
11
|
+
set_2 ? "#{set_1} #{set_2}" : set_1
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
namespace 'cuke_commander' do
|
16
|
+
|
17
|
+
task :clear_coverage do
|
18
|
+
puts 'Clearing old code coverage results...'
|
19
|
+
|
20
|
+
# Remove previous coverage results so that they don't get merged into the new results
|
21
|
+
code_coverage_directory = File.join(File.dirname(__FILE__), 'coverage')
|
22
|
+
FileUtils.remove_dir(code_coverage_directory, true) if File.exists?(code_coverage_directory)
|
23
|
+
end
|
24
|
+
|
25
|
+
desc 'Run all of the Cucumber features for the gem'
|
26
|
+
task :features, [:command_options] do |_t, args|
|
27
|
+
set_cucumber_options(combine_options('-t ~@wip -t ~@off', args[:command_options]))
|
28
|
+
end
|
29
|
+
Cucumber::Rake::Task.new(:features)
|
30
|
+
|
31
|
+
desc 'Run all of the RSpec specifications for the gem'
|
32
|
+
RSpec::Core::RakeTask.new(:specs, :command_options) do |t, args|
|
33
|
+
t.rspec_opts = "-t ~wip -t ~off "
|
34
|
+
t.rspec_opts << args[:command_options] if args[:command_options]
|
35
|
+
end
|
36
|
+
|
37
|
+
desc 'Test All The Things'
|
38
|
+
task :test_everything, [:command_options] => [:clear_coverage] do |_t, args|
|
39
|
+
Rake::Task['cuke_commander:specs'].invoke(args[:command_options])
|
40
|
+
Rake::Task['cuke_commander:features'].invoke(args[:command_options])
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
task :default => 'cuke_commander:test_everything'
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'cuke_commander/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "cuke_commander"
|
8
|
+
spec.version = CukeCommander::VERSION
|
9
|
+
spec.authors = ["Eric Kessler", 'Donavan Stanley']
|
10
|
+
spec.email = ["morrow748@gmail.com", 'stanleyd@grangeinsurance.com']
|
11
|
+
spec.description = %q{Command Cucumber}
|
12
|
+
spec.summary = %q{Provides an easy way to build a cucumber commandline.}
|
13
|
+
spec.homepage = "https://github.com/grange-insurance/cuke_commander"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency 'cucumber'
|
24
|
+
spec.add_development_dependency 'rspec'
|
25
|
+
spec.add_development_dependency 'simplecov'
|
26
|
+
end
|
@@ -0,0 +1,179 @@
|
|
1
|
+
Feature: Command line formatting
|
2
|
+
|
3
|
+
As a person who uses fancy cucumber command lines
|
4
|
+
I want to know command line formatting
|
5
|
+
So I can get the right command line
|
6
|
+
|
7
|
+
|
8
|
+
Background:
|
9
|
+
Given a command line generator
|
10
|
+
|
11
|
+
Scenario: Base format
|
12
|
+
When I ask for a cucumber command line with no additional options
|
13
|
+
Then I am given the following cucumber command line
|
14
|
+
| cucumber |
|
15
|
+
|
16
|
+
Scenario: Profile flag format
|
17
|
+
When I ask for a cucumber command line with the following profiles
|
18
|
+
| profile_1 |
|
19
|
+
Then I am given the following cucumber command line
|
20
|
+
| cucumber -p profile_1 |
|
21
|
+
When I ask for a cucumber command line with the following profiles
|
22
|
+
| profile_2 |
|
23
|
+
| profile_3 |
|
24
|
+
Then I am given the following cucumber command line
|
25
|
+
| cucumber -p profile_2 -p profile_3 |
|
26
|
+
|
27
|
+
Scenario: No-profile flag format
|
28
|
+
When I ask for a cucumber command line with a no-profile flag
|
29
|
+
Then I am given the following cucumber command line
|
30
|
+
| cucumber -P |
|
31
|
+
|
32
|
+
Scenario: Tag flag format
|
33
|
+
When I ask for a cucumber command line with the following tags
|
34
|
+
| @tag_1 |
|
35
|
+
Then I am given the following cucumber command line
|
36
|
+
| cucumber -t @tag_1 |
|
37
|
+
When I ask for a cucumber command line with the following tags
|
38
|
+
| @tag_2 |
|
39
|
+
| @tag_3,@tag4 |
|
40
|
+
Then I am given the following cucumber command line
|
41
|
+
| cucumber -t @tag_2 -t @tag_3,@tag4 |
|
42
|
+
|
43
|
+
Scenario: File-path flag format
|
44
|
+
When I ask for a cucumber command line with the following file-paths
|
45
|
+
| features/common |
|
46
|
+
Then I am given the following cucumber command line
|
47
|
+
| cucumber features/common |
|
48
|
+
When I ask for a cucumber command line with the following file-paths
|
49
|
+
| features/some_dir |
|
50
|
+
| features/some_other_dir |
|
51
|
+
Then I am given the following cucumber command line
|
52
|
+
| cucumber features/some_dir features/some_other_dir |
|
53
|
+
|
54
|
+
Scenario: Exclude pattern flag format
|
55
|
+
When I ask for a cucumber command line with the following exclude patterns
|
56
|
+
| pattern_1 |
|
57
|
+
Then I am given the following cucumber command line
|
58
|
+
| cucumber -e pattern_1 |
|
59
|
+
When I ask for a cucumber command line with the following exclude patterns
|
60
|
+
| pattern_2 |
|
61
|
+
| pattern_3 |
|
62
|
+
Then I am given the following cucumber command line
|
63
|
+
| cucumber -e pattern_2 -e pattern_3 |
|
64
|
+
|
65
|
+
Scenario: No-source flag format
|
66
|
+
When I ask for a cucumber command line with a no-source flag
|
67
|
+
Then I am given the following cucumber command line
|
68
|
+
| cucumber -s |
|
69
|
+
|
70
|
+
Scenario: No-color flag format
|
71
|
+
When I ask for a cucumber command line with a no-color flag
|
72
|
+
Then I am given the following cucumber command line
|
73
|
+
| cucumber --no-color |
|
74
|
+
|
75
|
+
Scenario: Color flag format
|
76
|
+
When I ask for a cucumber command line with a color flag
|
77
|
+
Then I am given the following cucumber command line
|
78
|
+
| cucumber --color |
|
79
|
+
|
80
|
+
Scenario: Formatter flag format
|
81
|
+
When I ask for a cucumber command line with the following formatters
|
82
|
+
| formatter | output_location |
|
83
|
+
| json | STDOUT |
|
84
|
+
Then I am given the following cucumber command line
|
85
|
+
| cucumber -f json -o STDOUT |
|
86
|
+
When I ask for a cucumber command line with the following formatters
|
87
|
+
| formatter | output_location |
|
88
|
+
| pretty | |
|
89
|
+
| html | output.html |
|
90
|
+
Then I am given the following cucumber command line
|
91
|
+
| cucumber -f pretty -f html -o output.html |
|
92
|
+
|
93
|
+
Scenario: Backtrace flag format
|
94
|
+
When I ask for a cucumber command line with a backtrace flag
|
95
|
+
Then I am given the following cucumber command line
|
96
|
+
| cucumber -b |
|
97
|
+
|
98
|
+
Scenario: Dry run flag format
|
99
|
+
When I ask for a cucumber command line with a dry run flag
|
100
|
+
Then I am given the following cucumber command line
|
101
|
+
| cucumber -d |
|
102
|
+
|
103
|
+
Scenario: Guess flag format
|
104
|
+
When I ask for a cucumber command line with a guess flag
|
105
|
+
Then I am given the following cucumber command line
|
106
|
+
| cucumber -g |
|
107
|
+
|
108
|
+
Scenario: WIP flag format
|
109
|
+
When I ask for a cucumber command line with a wip flag
|
110
|
+
Then I am given the following cucumber command line
|
111
|
+
| cucumber -w |
|
112
|
+
|
113
|
+
Scenario: Quiet flag format
|
114
|
+
When I ask for a cucumber command line with a quiet flag
|
115
|
+
Then I am given the following cucumber command line
|
116
|
+
| cucumber -q |
|
117
|
+
|
118
|
+
Scenario: Help flag format
|
119
|
+
When I ask for a cucumber command line with a help flag
|
120
|
+
Then I am given the following cucumber command line
|
121
|
+
| cucumber -h |
|
122
|
+
|
123
|
+
Scenario: Version flag format
|
124
|
+
When I ask for a cucumber command line with a version flag
|
125
|
+
Then I am given the following cucumber command line
|
126
|
+
| cucumber --version |
|
127
|
+
|
128
|
+
Scenario: Strict flag format
|
129
|
+
When I ask for a cucumber command line with a strict flag
|
130
|
+
Then I am given the following cucumber command line
|
131
|
+
| cucumber -S |
|
132
|
+
|
133
|
+
Scenario: Verbose flag format
|
134
|
+
When I ask for a cucumber command line with a verbose flag
|
135
|
+
Then I am given the following cucumber command line
|
136
|
+
| cucumber -v |
|
137
|
+
|
138
|
+
Scenario: Expand flag format
|
139
|
+
When I ask for a cucumber command line with an expand flag
|
140
|
+
Then I am given the following cucumber command line
|
141
|
+
| cucumber -x |
|
142
|
+
|
143
|
+
Scenario: Name flag format
|
144
|
+
When I ask for a cucumber command line with the name patterns
|
145
|
+
| pattern_1 |
|
146
|
+
Then I am given the following cucumber command line
|
147
|
+
| cucumber -n pattern_1 |
|
148
|
+
When I ask for a cucumber command line with the name patterns
|
149
|
+
| pattern_2 |
|
150
|
+
| pattern_3 |
|
151
|
+
Then I am given the following cucumber command line
|
152
|
+
| cucumber -n pattern_2 -n pattern_3 |
|
153
|
+
|
154
|
+
Scenario: Require flag format
|
155
|
+
When I ask for a cucumber command line with the following required files
|
156
|
+
| features/foo.rb |
|
157
|
+
Then I am given the following cucumber command line
|
158
|
+
| cucumber -r features/foo.rb |
|
159
|
+
When I ask for a cucumber command line with the following required files
|
160
|
+
| features/bar.rb |
|
161
|
+
| features/bar/baz.rb |
|
162
|
+
Then I am given the following cucumber command line
|
163
|
+
| cucumber -r features/bar.rb -r features/bar/baz.rb |
|
164
|
+
|
165
|
+
Scenario: Additional options format
|
166
|
+
|
167
|
+
The additional options will be added to the end of the command line. This behavior allows for modifying
|
168
|
+
the generated command line due to Cucumber options that this gem has not implemented or to handle possible
|
169
|
+
extensions made to Cucumber by the user or, really, for any reason at all.
|
170
|
+
|
171
|
+
When I ask for a cucumber command line with the following additional options
|
172
|
+
| --expand |
|
173
|
+
Then I am given the following cucumber command line
|
174
|
+
| cucumber --expand |
|
175
|
+
When I ask for a cucumber command line with the following additional options
|
176
|
+
| -d |
|
177
|
+
| fooBAR!!! |
|
178
|
+
Then I am given the following cucumber command line
|
179
|
+
| cucumber -d fooBAR!!! |
|
@@ -0,0 +1,46 @@
|
|
1
|
+
Feature: Cucumber options
|
2
|
+
|
3
|
+
As a person who uses fancy cucumber command lines
|
4
|
+
I want to know about the available cucumber options
|
5
|
+
So that I can use them correctly
|
6
|
+
|
7
|
+
|
8
|
+
Scenario: Available Cucumber options
|
9
|
+
* The following Cucumber options are available for use:
|
10
|
+
| profiles |
|
11
|
+
| tags |
|
12
|
+
| file_paths |
|
13
|
+
| excludes |
|
14
|
+
| no_source |
|
15
|
+
| formatters |
|
16
|
+
| no_color |
|
17
|
+
| color |
|
18
|
+
| requires |
|
19
|
+
| names |
|
20
|
+
| dry_run |
|
21
|
+
| backtrace |
|
22
|
+
| strict |
|
23
|
+
| verbose |
|
24
|
+
| expand |
|
25
|
+
| version |
|
26
|
+
| help |
|
27
|
+
| quiet |
|
28
|
+
| wip |
|
29
|
+
| guess |
|
30
|
+
| no_profile |
|
31
|
+
| options |
|
32
|
+
|
33
|
+
Scenario: Generator will accept known options
|
34
|
+
Given a command line generator
|
35
|
+
When I ask for a cucumber command line with a valid option
|
36
|
+
Then the generator will not error
|
37
|
+
|
38
|
+
Scenario: Unknown options trigger an error
|
39
|
+
Given a command line generator
|
40
|
+
When I ask for a Cucumber command line with an invalid option
|
41
|
+
Then the generator will error
|
42
|
+
|
43
|
+
Scenario: Invalid option values trigger an error
|
44
|
+
Given a command line generator
|
45
|
+
When I ask for a Cucumber command line with an invalid option value
|
46
|
+
Then the generator will error
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Feature: Command line generation
|
2
|
+
|
3
|
+
As a person who uses fancy cucumber command lines
|
4
|
+
I want to have them made for me
|
5
|
+
In order to not have to build it myself on the fly
|
6
|
+
|
7
|
+
|
8
|
+
Scenario: Can generate a command line
|
9
|
+
Given a command line generator
|
10
|
+
When I ask for a cucumber command line
|
11
|
+
Then I am given a cucumber command line
|
@@ -0,0 +1,156 @@
|
|
1
|
+
When(/^I ask for a cucumber command line$/) do
|
2
|
+
@command_line = @commander.generate_command_line
|
3
|
+
end
|
4
|
+
|
5
|
+
When(/^I ask for a cucumber command line with no additional options$/) do
|
6
|
+
@command_line = @commander.generate_command_line
|
7
|
+
end
|
8
|
+
|
9
|
+
When(/^I ask for a cucumber command line with the following profiles$/) do |profiles|
|
10
|
+
options = {profiles: profiles.raw.flatten}
|
11
|
+
@command_line = @commander.generate_command_line(options)
|
12
|
+
end
|
13
|
+
|
14
|
+
When(/^I ask for a cucumber command line with a no\-profile flag$/) do
|
15
|
+
@options = {no_profile: true}
|
16
|
+
@command_line = @commander.generate_command_line(@options)
|
17
|
+
end
|
18
|
+
|
19
|
+
When(/^I ask for a cucumber command line with the following tags$/) do |tags|
|
20
|
+
@options = {tags: tags.raw.flatten}
|
21
|
+
@command_line = @commander.generate_command_line(@options)
|
22
|
+
end
|
23
|
+
|
24
|
+
When(/^I ask for a cucumber command line with the following file-paths$/) do |table|
|
25
|
+
@options = {file_paths: table.raw.flatten}
|
26
|
+
@command_line = @commander.generate_command_line(@options)
|
27
|
+
end
|
28
|
+
|
29
|
+
When(/^I ask for a cucumber command line with the following exclude patterns$/) do |table|
|
30
|
+
@options = {excludes: table.raw.flatten}
|
31
|
+
@command_line = @commander.generate_command_line(@options)
|
32
|
+
end
|
33
|
+
|
34
|
+
When(/^I ask for a cucumber command line with a no-source flag$/) do
|
35
|
+
@options = {no_source: true}
|
36
|
+
@command_line = @commander.generate_command_line(@options)
|
37
|
+
end
|
38
|
+
|
39
|
+
When(/^I ask for a cucumber command line with a no-color flag$/) do
|
40
|
+
@options = {no_color: true}
|
41
|
+
@command_line = @commander.generate_command_line(@options)
|
42
|
+
end
|
43
|
+
|
44
|
+
When(/^I ask for a cucumber command line with a color flag$/) do
|
45
|
+
@options = {color: true}
|
46
|
+
@command_line = @commander.generate_command_line(@options)
|
47
|
+
end
|
48
|
+
|
49
|
+
When(/^I ask for a cucumber command line with the following formatters$/) do |table|
|
50
|
+
table = table.raw
|
51
|
+
table.shift
|
52
|
+
|
53
|
+
@options = {formatters: Hash[table]}
|
54
|
+
@command_line = @commander.generate_command_line(@options)
|
55
|
+
end
|
56
|
+
|
57
|
+
When(/^I ask for a Cucumber command line with an invalid option value$/) do
|
58
|
+
options = {:tags => :bad_tag_value}
|
59
|
+
|
60
|
+
begin
|
61
|
+
@error_encountered = false
|
62
|
+
@commander.generate_command_line(options)
|
63
|
+
rescue ArgumentError => e
|
64
|
+
@error_message = e.message
|
65
|
+
@error_encountered = true
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
When(/^I ask for a Cucumber command line with an invalid option$/) do
|
70
|
+
options = {not_a_valid_option: 'some value'}
|
71
|
+
|
72
|
+
begin
|
73
|
+
@error_encountered = false
|
74
|
+
@commander.generate_command_line(options)
|
75
|
+
rescue ArgumentError => e
|
76
|
+
@error_message = e.message
|
77
|
+
@error_encountered = true
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
When(/^I ask for a cucumber command line with a valid option$/) do
|
82
|
+
options = {tags: 'foo'}
|
83
|
+
|
84
|
+
begin
|
85
|
+
@error_encountered = false
|
86
|
+
@commander.generate_command_line(options)
|
87
|
+
rescue ArgumentError => e
|
88
|
+
@error_message = e.message
|
89
|
+
@error_encountered = true
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
When(/I ask for a cucumber command line with the following additional options$/) do |options|
|
94
|
+
@options = {options: options.raw.flatten}
|
95
|
+
@command_line = @commander.generate_command_line(@options)
|
96
|
+
end
|
97
|
+
|
98
|
+
When(/^I ask for a cucumber command line with a backtrace flag$/) do
|
99
|
+
@options = {backtrace: true}
|
100
|
+
@command_line = @commander.generate_command_line(@options)
|
101
|
+
end
|
102
|
+
|
103
|
+
When(/^I ask for a cucumber command line with a dry run flag$/) do
|
104
|
+
@options = {dry_run: true}
|
105
|
+
@command_line = @commander.generate_command_line(@options)
|
106
|
+
end
|
107
|
+
|
108
|
+
When(/^I ask for a cucumber command line with a guess flag$/) do
|
109
|
+
@options = {guess: true}
|
110
|
+
@command_line = @commander.generate_command_line(@options)
|
111
|
+
end
|
112
|
+
|
113
|
+
When(/^I ask for a cucumber command line with a wip flag$/) do
|
114
|
+
@options = {wip: true}
|
115
|
+
@command_line = @commander.generate_command_line(@options)
|
116
|
+
end
|
117
|
+
|
118
|
+
When(/^I ask for a cucumber command line with a quiet flag$/) do
|
119
|
+
@options = {quiet: true}
|
120
|
+
@command_line = @commander.generate_command_line(@options)
|
121
|
+
end
|
122
|
+
|
123
|
+
When(/^I ask for a cucumber command line with a help flag$/) do
|
124
|
+
@options = {help: true}
|
125
|
+
@command_line = @commander.generate_command_line(@options)
|
126
|
+
end
|
127
|
+
|
128
|
+
When(/^I ask for a cucumber command line with a version flag$/) do
|
129
|
+
@options = {version: true}
|
130
|
+
@command_line = @commander.generate_command_line(@options)
|
131
|
+
end
|
132
|
+
|
133
|
+
When(/^I ask for a cucumber command line with a strict flag$/) do
|
134
|
+
@options = {strict: true}
|
135
|
+
@command_line = @commander.generate_command_line(@options)
|
136
|
+
end
|
137
|
+
|
138
|
+
When(/^I ask for a cucumber command line with a verbose flag$/) do
|
139
|
+
@options = {verbose: true}
|
140
|
+
@command_line = @commander.generate_command_line(@options)
|
141
|
+
end
|
142
|
+
|
143
|
+
When(/^I ask for a cucumber command line with an expand flag$/) do
|
144
|
+
@options = {expand: true}
|
145
|
+
@command_line = @commander.generate_command_line(@options)
|
146
|
+
end
|
147
|
+
|
148
|
+
When(/^I ask for a cucumber command line with the name patterns$/) do |names|
|
149
|
+
options = {names: names.raw.flatten}
|
150
|
+
@command_line = @commander.generate_command_line(options)
|
151
|
+
end
|
152
|
+
|
153
|
+
When(/^I ask for a cucumber command line with the following required files$/) do |requires|
|
154
|
+
options = {requires: requires.raw.flatten}
|
155
|
+
@command_line = @commander.generate_command_line(options)
|
156
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
Then(/^I am given a cucumber command line$/) do
|
2
|
+
expect(@command_line).to include("cucumber")
|
3
|
+
end
|
4
|
+
|
5
|
+
Then(/^I am given the following cucumber command line$/) do |line|
|
6
|
+
expect(@command_line).to eq(line.raw.flatten.first)
|
7
|
+
end
|
8
|
+
|
9
|
+
Then(/^the generator (will|will not) error$/) do |will_or_will_not|
|
10
|
+
if will_or_will_not == 'will'
|
11
|
+
raise("Expected error, did not error") unless @error_encountered
|
12
|
+
else
|
13
|
+
raise("Expected no error, but got: #{@error_message}") if @error_encountered
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
And(/^The following Cucumber options are available for use:$/) do |valid_options|
|
18
|
+
expect(CukeCommander::CUKE_OPTIONS).to match_array(valid_options.raw.flatten)
|
19
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require "cuke_commander/version"
|
2
|
+
require "cuke_commander/cl_generator"
|
3
|
+
|
4
|
+
|
5
|
+
# Top level module under which the gem code lives.
|
6
|
+
module CukeCommander
|
7
|
+
|
8
|
+
# The Cucumber options that are currently supported by the gem.
|
9
|
+
CUKE_OPTIONS = %w{ profiles tags file_paths formatters excludes no_source no_color options backtrace color dry_run expand guess help names no_profile quiet requires strict verbose version wip}
|
10
|
+
end
|
@@ -0,0 +1,208 @@
|
|
1
|
+
module CukeCommander
|
2
|
+
|
3
|
+
# The object responsible for generating Cucumber command lines.
|
4
|
+
class CLGenerator
|
5
|
+
|
6
|
+
# Generates a Cucumber command line.
|
7
|
+
#
|
8
|
+
# Most option values are either an Array or a boolean value. In the case of the former, a
|
9
|
+
# String can be used instead of an Array when only a single value is needed. Some option
|
10
|
+
# values come in pairs (e.g. formatters and their output locations). These option values
|
11
|
+
# are taken as a Hash where a key is the first part of the pair and the key's value is the
|
12
|
+
# second part.
|
13
|
+
#
|
14
|
+
# @param options [Hash] the Cucumber options that the command line should include.
|
15
|
+
def generate_command_line(options = {})
|
16
|
+
validate_options(options)
|
17
|
+
command_line = 'cucumber'
|
18
|
+
|
19
|
+
append_options(command_line, wrap_options(options[:profiles]), '-p') if options[:profiles]
|
20
|
+
append_options(command_line, wrap_options(options[:names]), '-n') if options[:names]
|
21
|
+
append_options(command_line, wrap_options(options[:tags]), '-t') if options[:tags]
|
22
|
+
append_options(command_line, wrap_options(options[:file_paths])) if options[:file_paths]
|
23
|
+
append_options(command_line, wrap_options(options[:excludes]), '-e') if options[:excludes]
|
24
|
+
append_options(command_line, wrap_options(options[:requires]), '-r') if options[:requires]
|
25
|
+
append_option(command_line, '-s') if options[:no_source]
|
26
|
+
|
27
|
+
if options[:formatters]
|
28
|
+
options[:formatters].each do |format, output_location|
|
29
|
+
append_option(command_line, format, '-f')
|
30
|
+
append_option(command_line, output_location, '-o') unless output_location.to_s.empty?
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
append_option(command_line, '--no-color') if options[:no_color]
|
35
|
+
append_option(command_line, '--color') if options[:color]
|
36
|
+
append_option(command_line, '-b') if options[:backtrace]
|
37
|
+
append_option(command_line, '-d') if options[:dry_run]
|
38
|
+
append_option(command_line, '-P') if options[:no_profile]
|
39
|
+
append_option(command_line, '-g') if options[:guess]
|
40
|
+
append_option(command_line, '-w') if options[:wip]
|
41
|
+
append_option(command_line, '-q') if options[:quiet]
|
42
|
+
append_option(command_line, '-v') if options[:verbose]
|
43
|
+
append_option(command_line, '--version') if options[:version]
|
44
|
+
append_option(command_line, '-h') if options[:help]
|
45
|
+
append_option(command_line, '-x') if options[:expand]
|
46
|
+
append_option(command_line, '-S') if options[:strict]
|
47
|
+
|
48
|
+
append_options(command_line, wrap_options(options[:options])) if options[:options]
|
49
|
+
|
50
|
+
command_line
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
|
57
|
+
def validate_options(options)
|
58
|
+
raise(ArgumentError, "Argument must be a Hash, got: #{options.class}") unless options.is_a?(Hash)
|
59
|
+
|
60
|
+
options.each_key do |option|
|
61
|
+
raise(ArgumentError, "Option: #{option}, is not a cucumber option") unless CUKE_OPTIONS.include?(option.to_s)
|
62
|
+
end
|
63
|
+
|
64
|
+
raise_invalid_error('Profiles', 'a String or Array', options[:profiles]) unless valid_profiles?(options[:profiles])
|
65
|
+
raise_invalid_error('Tags', 'a String or Array', options[:tags]) unless valid_tags?(options[:tags])
|
66
|
+
raise_invalid_error('File path', 'a String or Array', options[:file_paths]) unless valid_file_paths?(options[:file_paths])
|
67
|
+
raise_invalid_error('Formatters', 'a Hash', options[:formatters]) unless valid_formatters?(options[:formatters])
|
68
|
+
raise_invalid_error('Excludes', 'a String or Array', options[:excludes]) unless valid_excludes?(options[:excludes])
|
69
|
+
raise_invalid_error('No-source', 'true or false', options[:no_source]) unless valid_no_source?(options[:no_source])
|
70
|
+
raise_invalid_error('No-color', 'true or false', options[:no_color]) unless valid_no_color?(options[:no_color])
|
71
|
+
raise_invalid_error('Color', 'true or false', options[:color]) unless valid_color?(options[:color])
|
72
|
+
raise_invalid_error('Backtrace', 'true or false', options[:backtrace]) unless valid_backtrace?(options[:backtrace])
|
73
|
+
raise_invalid_error('Expand', 'true or false', options[:expand]) unless valid_expand?(options[:expand])
|
74
|
+
raise_invalid_error('Guess', 'true or false', options[:guess]) unless valid_guess?(options[:guess])
|
75
|
+
raise_invalid_error('Help', 'true or false', options[:help]) unless valid_help?(options[:help])
|
76
|
+
raise_invalid_error('Dry run', 'true or false', options[:dry_run]) unless valid_dry_run?(options[:dry_run])
|
77
|
+
raise_invalid_error('No profile', 'true or false', options[:no_profile]) unless valid_no_profile?(options[:no_profile])
|
78
|
+
raise_invalid_error('Quiet', 'true or false', options[:quiet]) unless valid_quiet?(options[:quiet])
|
79
|
+
raise_invalid_error('Strict', 'true or false', options[:strict]) unless valid_strict?(options[:strict])
|
80
|
+
raise_invalid_error('Verbose', 'true or false', options[:verbose]) unless valid_verbose?(options[:verbose])
|
81
|
+
raise_invalid_error('Version', 'true or false', options[:version]) unless valid_version?(options[:version])
|
82
|
+
raise_invalid_error('Wip', 'true or false', options[:wip]) unless valid_wip?(options[:wip])
|
83
|
+
raise_invalid_error('Names', 'a String or Array', options[:names]) unless valid_names?(options[:names])
|
84
|
+
raise_invalid_error('Requires', 'a String or Array', options[:requires]) unless valid_requires?(options[:requires])
|
85
|
+
raise_invalid_error('Options', 'a String or Array', options[:options]) unless valid_options?(options[:options])
|
86
|
+
end
|
87
|
+
|
88
|
+
def append_options(command, option_set, flag= nil)
|
89
|
+
option_set.each do |option|
|
90
|
+
append_option(command, option, flag)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def append_option(command, option, flag= nil)
|
95
|
+
command << " #{flag}" if flag
|
96
|
+
command << " #{option}"
|
97
|
+
end
|
98
|
+
|
99
|
+
def wrap_options(option_set)
|
100
|
+
option_set.is_a?(Array) ? option_set : [option_set]
|
101
|
+
end
|
102
|
+
|
103
|
+
def raise_invalid_error(option, valid_types, value_used)
|
104
|
+
raise(ArgumentError, "#{option} option must be #{valid_types}, got: #{value_used.class}")
|
105
|
+
end
|
106
|
+
|
107
|
+
def valid_profiles?(profiles)
|
108
|
+
valid_string_array_value?(profiles)
|
109
|
+
end
|
110
|
+
|
111
|
+
def valid_tags?(tags)
|
112
|
+
valid_string_array_value?(tags)
|
113
|
+
end
|
114
|
+
|
115
|
+
def valid_file_paths?(file_paths)
|
116
|
+
valid_string_array_value?(file_paths)
|
117
|
+
end
|
118
|
+
|
119
|
+
def valid_formatters?(formatters)
|
120
|
+
valid_hash_value?(formatters)
|
121
|
+
end
|
122
|
+
|
123
|
+
def valid_excludes?(excludes)
|
124
|
+
valid_string_array_value?(excludes)
|
125
|
+
end
|
126
|
+
|
127
|
+
def valid_no_source?(no_source)
|
128
|
+
valid_boolean_value?(no_source)
|
129
|
+
end
|
130
|
+
|
131
|
+
def valid_no_color?(no_color)
|
132
|
+
valid_boolean_value?(no_color)
|
133
|
+
end
|
134
|
+
|
135
|
+
def valid_color?(color)
|
136
|
+
valid_boolean_value?(color)
|
137
|
+
end
|
138
|
+
|
139
|
+
def valid_backtrace?(backtrace)
|
140
|
+
valid_boolean_value?(backtrace)
|
141
|
+
end
|
142
|
+
|
143
|
+
def valid_wip?(wip)
|
144
|
+
valid_boolean_value?(wip)
|
145
|
+
end
|
146
|
+
|
147
|
+
def valid_no_profile?(no_profile)
|
148
|
+
valid_boolean_value?(no_profile)
|
149
|
+
end
|
150
|
+
|
151
|
+
def valid_expand?(expand)
|
152
|
+
valid_boolean_value?(expand)
|
153
|
+
end
|
154
|
+
|
155
|
+
def valid_strict?(strict)
|
156
|
+
valid_boolean_value?(strict)
|
157
|
+
end
|
158
|
+
|
159
|
+
def valid_verbose?(verbose)
|
160
|
+
valid_boolean_value?(verbose)
|
161
|
+
end
|
162
|
+
|
163
|
+
def valid_version?(version)
|
164
|
+
valid_boolean_value?(version)
|
165
|
+
end
|
166
|
+
|
167
|
+
def valid_quiet?(quiet)
|
168
|
+
valid_boolean_value?(quiet)
|
169
|
+
end
|
170
|
+
|
171
|
+
def valid_guess?(guess)
|
172
|
+
valid_boolean_value?(guess)
|
173
|
+
end
|
174
|
+
|
175
|
+
def valid_help?(help)
|
176
|
+
valid_boolean_value?(help)
|
177
|
+
end
|
178
|
+
|
179
|
+
def valid_dry_run?(dry_run)
|
180
|
+
valid_boolean_value?(dry_run)
|
181
|
+
end
|
182
|
+
|
183
|
+
def valid_names?(names)
|
184
|
+
valid_string_array_value?(names)
|
185
|
+
end
|
186
|
+
|
187
|
+
def valid_requires?(requires)
|
188
|
+
valid_string_array_value?(requires)
|
189
|
+
end
|
190
|
+
|
191
|
+
def valid_options?(options)
|
192
|
+
valid_string_array_value?(options)
|
193
|
+
end
|
194
|
+
|
195
|
+
def valid_string_array_value?(value)
|
196
|
+
value.nil? || value.is_a?(Array) || value.is_a?(String)
|
197
|
+
end
|
198
|
+
|
199
|
+
def valid_boolean_value?(value)
|
200
|
+
value.nil? || (value == true) || (value == false)
|
201
|
+
end
|
202
|
+
|
203
|
+
def valid_hash_value?(value)
|
204
|
+
value.nil? || value.is_a?(Hash)
|
205
|
+
end
|
206
|
+
|
207
|
+
end
|
208
|
+
end
|
@@ -0,0 +1,249 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
|
4
|
+
describe 'CLGenerator, Unit' do
|
5
|
+
|
6
|
+
let(:clazz) { CukeCommander::CLGenerator }
|
7
|
+
let(:generator) { clazz.new }
|
8
|
+
|
9
|
+
|
10
|
+
it 'is defined' do
|
11
|
+
expect(CukeCommander.const_defined?(:CLGenerator)).to be true
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'can generate a command line' do
|
15
|
+
expect(generator).to respond_to(:generate_command_line)
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'returns a string that represents a Cucumber command line' do
|
19
|
+
expect(generator.generate_command_line).to be_a String
|
20
|
+
expect(generator.generate_command_line).to match(/^cucumber ?/)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'can build a command line based on options' do
|
24
|
+
expect(generator.method(:generate_command_line).arity).to eq(-1)
|
25
|
+
end
|
26
|
+
|
27
|
+
describe 'option handling' do
|
28
|
+
|
29
|
+
all_options = {profiles: 'foo',
|
30
|
+
tags: 'foo',
|
31
|
+
file_paths: 'foo',
|
32
|
+
formatters: {some_formatter: 'some_file.txt'},
|
33
|
+
excludes: 'foo',
|
34
|
+
no_source: true,
|
35
|
+
no_color: true,
|
36
|
+
options: 'foo',
|
37
|
+
backtrace: true,
|
38
|
+
color: true,
|
39
|
+
dry_run: true,
|
40
|
+
expand: true,
|
41
|
+
guess: true,
|
42
|
+
help: true,
|
43
|
+
names: 'foo',
|
44
|
+
no_profile: true,
|
45
|
+
quiet: true,
|
46
|
+
requires: 'foo',
|
47
|
+
strict: true,
|
48
|
+
verbose: true,
|
49
|
+
version: true,
|
50
|
+
wip: true
|
51
|
+
}
|
52
|
+
|
53
|
+
let(:test_options) { all_options.dup }
|
54
|
+
let(:bad_value) { 7 }
|
55
|
+
|
56
|
+
before(:all) do
|
57
|
+
# Not an actual test but here to make sure that the test data is
|
58
|
+
# updated when options are added or removed
|
59
|
+
expect(all_options.keys).to match_array(CukeCommander::CUKE_OPTIONS.collect { |option| option.to_sym })
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'can handle generating a command line when no options are provided' do
|
63
|
+
expect { generator.generate_command_line }.to_not raise_exception
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'can handle generating a command line when all options are provided' do
|
67
|
+
expect { generator.generate_command_line(all_options) }.to_not raise_exception
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'only accepts cucumber options' do
|
71
|
+
options = {:not_a_cucumber_option => ['123', '345', '678']}
|
72
|
+
expect { generator.generate_command_line(options) }.to raise_exception
|
73
|
+
end
|
74
|
+
|
75
|
+
CukeCommander::CUKE_OPTIONS.each do |option|
|
76
|
+
|
77
|
+
it "can handle generating a command line when the '#{option}' option is provided" do
|
78
|
+
test_options.keep_if { |key, value| key == option }
|
79
|
+
|
80
|
+
expect { generator.generate_command_line }.to_not raise_exception
|
81
|
+
end
|
82
|
+
|
83
|
+
it "can handle generating a command line when the '#{option}' option is not provided" do
|
84
|
+
test_options.delete_if { |key, value| key == option }
|
85
|
+
|
86
|
+
expect { generator.generate_command_line }.to_not raise_exception
|
87
|
+
end
|
88
|
+
|
89
|
+
it "validates the '#{option}' option" do
|
90
|
+
test_options[option.to_sym] = bad_value
|
91
|
+
|
92
|
+
expect { generator.generate_command_line(test_options) }.to raise_error(ArgumentError, /must.*got.*#{bad_value.class}/)
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'only accepts an options Hash as an argument' do
|
98
|
+
options = [1, 2, 3]
|
99
|
+
|
100
|
+
expect { generator.generate_command_line(options) }.to raise_error(ArgumentError, /must.*Hash.*got.*#{options.class}/)
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'only accepts a string or array as a profile value' do
|
104
|
+
expect { generator.generate_command_line({profiles: 'foo'}) }.to_not raise_error
|
105
|
+
expect { generator.generate_command_line({profiles: ['foo', 'bar']}) }.to_not raise_error
|
106
|
+
expect { generator.generate_command_line({profiles: bad_value}) }.to raise_error(ArgumentError, /must.*String or Array.*got.*#{bad_value.class}/)
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'only accepts a string or array as a tag value' do
|
110
|
+
expect { generator.generate_command_line({tags: 'foo'}) }.to_not raise_error
|
111
|
+
expect { generator.generate_command_line({tags: ['foo', 'bar']}) }.to_not raise_error
|
112
|
+
expect { generator.generate_command_line({tags: bad_value}) }.to raise_error(ArgumentError, /must.*String or Array.*got.*#{bad_value.class}/)
|
113
|
+
end
|
114
|
+
|
115
|
+
it 'only accepts a string or array as a file path value' do
|
116
|
+
expect { generator.generate_command_line({file_paths: 'foo'}) }.to_not raise_error
|
117
|
+
expect { generator.generate_command_line({file_paths: ['foo', 'bar']}) }.to_not raise_error
|
118
|
+
expect { generator.generate_command_line({file_paths: bad_value}) }.to raise_error(ArgumentError, /must.*String or Array.*got.*#{bad_value.class}/)
|
119
|
+
end
|
120
|
+
|
121
|
+
it 'only accepts a hash as a formatters value' do
|
122
|
+
expect { generator.generate_command_line({formatters: {}}) }.to_not raise_error
|
123
|
+
expect { generator.generate_command_line({formatters: bad_value}) }.to raise_error(ArgumentError, /must.*Hash.*got.*#{bad_value.class}/)
|
124
|
+
end
|
125
|
+
|
126
|
+
it 'only accepts a string or array as an excluded patterns value' do
|
127
|
+
expect { generator.generate_command_line({excludes: 'foo'}) }.to_not raise_error
|
128
|
+
expect { generator.generate_command_line({excludes: ['foo', 'bar']}) }.to_not raise_error
|
129
|
+
expect { generator.generate_command_line({excludes: bad_value}) }.to raise_error(ArgumentError, /must.*String or Array.*got.*#{bad_value.class}/)
|
130
|
+
end
|
131
|
+
|
132
|
+
it 'only accepts a boolean as a no-source value' do
|
133
|
+
expect { generator.generate_command_line({no_source: true}) }.to_not raise_error
|
134
|
+
expect { generator.generate_command_line({no_source: false}) }.to_not raise_error
|
135
|
+
expect { generator.generate_command_line({no_source: bad_value}) }.to raise_error(ArgumentError, /must.*true or false.*got.*#{bad_value.class}/)
|
136
|
+
end
|
137
|
+
|
138
|
+
it 'only accepts a boolean as a no-color value' do
|
139
|
+
expect { generator.generate_command_line({no_color: true}) }.to_not raise_error
|
140
|
+
expect { generator.generate_command_line({no_color: false}) }.to_not raise_error
|
141
|
+
expect { generator.generate_command_line({no_color: bad_value}) }.to raise_error(ArgumentError, /must.*true or false.*got.*#{bad_value.class}/)
|
142
|
+
end
|
143
|
+
|
144
|
+
it 'only accepts a boolean as a color value' do
|
145
|
+
expect { generator.generate_command_line({color: true}) }.to_not raise_error
|
146
|
+
expect { generator.generate_command_line({color: false}) }.to_not raise_error
|
147
|
+
expect { generator.generate_command_line({color: bad_value}) }.to raise_error(ArgumentError, /must.*true or false.*got.*#{bad_value.class}/)
|
148
|
+
end
|
149
|
+
|
150
|
+
it 'only accepts a boolean as a backtrace value' do
|
151
|
+
expect { generator.generate_command_line({backtrace: true}) }.to_not raise_error
|
152
|
+
expect { generator.generate_command_line({backtrace: false}) }.to_not raise_error
|
153
|
+
expect { generator.generate_command_line({backtrace: bad_value}) }.to raise_error(ArgumentError, /must.*true or false.*got.*#{bad_value.class}/)
|
154
|
+
end
|
155
|
+
|
156
|
+
it 'only accepts a boolean as a dry run value' do
|
157
|
+
expect { generator.generate_command_line({dry_run: true}) }.to_not raise_error
|
158
|
+
expect { generator.generate_command_line({dry_run: false}) }.to_not raise_error
|
159
|
+
expect { generator.generate_command_line({dry_run: bad_value}) }.to raise_error(ArgumentError, /must.*true or false.*got.*#{bad_value.class}/)
|
160
|
+
end
|
161
|
+
|
162
|
+
it 'only accepts a boolean as an expand value' do
|
163
|
+
expect { generator.generate_command_line({expand: true}) }.to_not raise_error
|
164
|
+
expect { generator.generate_command_line({expand: false}) }.to_not raise_error
|
165
|
+
expect { generator.generate_command_line({expand: bad_value}) }.to raise_error(ArgumentError, /must.*true or false.*got.*#{bad_value.class}/)
|
166
|
+
end
|
167
|
+
|
168
|
+
it 'only accepts a boolean as a guess value' do
|
169
|
+
expect { generator.generate_command_line({guess: true}) }.to_not raise_error
|
170
|
+
expect { generator.generate_command_line({guess: false}) }.to_not raise_error
|
171
|
+
expect { generator.generate_command_line({guess: bad_value}) }.to raise_error(ArgumentError, /must.*true or false.*got.*#{bad_value.class}/)
|
172
|
+
end
|
173
|
+
|
174
|
+
it 'only accepts a boolean as a help value' do
|
175
|
+
expect { generator.generate_command_line({help: true}) }.to_not raise_error
|
176
|
+
expect { generator.generate_command_line({help: false}) }.to_not raise_error
|
177
|
+
expect { generator.generate_command_line({help: bad_value}) }.to raise_error(ArgumentError, /must.*true or false.*got.*#{bad_value.class}/)
|
178
|
+
end
|
179
|
+
|
180
|
+
it 'only accepts a boolean as a quiet value' do
|
181
|
+
expect { generator.generate_command_line({quiet: true}) }.to_not raise_error
|
182
|
+
expect { generator.generate_command_line({quiet: false}) }.to_not raise_error
|
183
|
+
expect { generator.generate_command_line({quiet: bad_value}) }.to raise_error(ArgumentError, /must.*true or false.*got.*#{bad_value.class}/)
|
184
|
+
end
|
185
|
+
|
186
|
+
it 'only accepts a boolean as a strict value' do
|
187
|
+
expect { generator.generate_command_line({strict: true}) }.to_not raise_error
|
188
|
+
expect { generator.generate_command_line({strict: false}) }.to_not raise_error
|
189
|
+
expect { generator.generate_command_line({strict: bad_value}) }.to raise_error(ArgumentError, /must.*true or false.*got.*#{bad_value.class}/)
|
190
|
+
end
|
191
|
+
|
192
|
+
it 'only accepts a boolean as a verbose value' do
|
193
|
+
expect { generator.generate_command_line({verbose: true}) }.to_not raise_error
|
194
|
+
expect { generator.generate_command_line({verbose: false}) }.to_not raise_error
|
195
|
+
expect { generator.generate_command_line({verbose: bad_value}) }.to raise_error(ArgumentError, /must.*true or false.*got.*#{bad_value.class}/)
|
196
|
+
end
|
197
|
+
|
198
|
+
it 'only accepts a boolean as a version value' do
|
199
|
+
expect { generator.generate_command_line({version: true}) }.to_not raise_error
|
200
|
+
expect { generator.generate_command_line({version: false}) }.to_not raise_error
|
201
|
+
expect { generator.generate_command_line({version: bad_value}) }.to raise_error(ArgumentError, /must.*true or false.*got.*#{bad_value.class}/)
|
202
|
+
end
|
203
|
+
|
204
|
+
it 'only accepts a boolean as a wip value' do
|
205
|
+
expect { generator.generate_command_line({wip: true}) }.to_not raise_error
|
206
|
+
expect { generator.generate_command_line({wip: false}) }.to_not raise_error
|
207
|
+
expect { generator.generate_command_line({wip: bad_value}) }.to raise_error(ArgumentError, /must.*true or false.*got.*#{bad_value.class}/)
|
208
|
+
end
|
209
|
+
|
210
|
+
it 'only accepts a boolean as a no profile value' do
|
211
|
+
expect { generator.generate_command_line({no_profile: true}) }.to_not raise_error
|
212
|
+
expect { generator.generate_command_line({no_profile: false}) }.to_not raise_error
|
213
|
+
expect { generator.generate_command_line({no_profile: bad_value}) }.to raise_error(ArgumentError, /must.*true or false.*got.*#{bad_value.class}/)
|
214
|
+
end
|
215
|
+
|
216
|
+
it 'only accepts a string or array as a require value' do
|
217
|
+
expect { generator.generate_command_line({requires: 'foo'}) }.to_not raise_error
|
218
|
+
expect { generator.generate_command_line({requires: ['foo', 'bar']}) }.to_not raise_error
|
219
|
+
expect { generator.generate_command_line({requires: bad_value}) }.to raise_error(ArgumentError, /must.*String or Array.*got.*#{bad_value.class}/)
|
220
|
+
end
|
221
|
+
|
222
|
+
it 'only accepts a string or array as a name value' do
|
223
|
+
expect { generator.generate_command_line({names: 'foo'}) }.to_not raise_error
|
224
|
+
expect { generator.generate_command_line({names: ['foo', 'bar']}) }.to_not raise_error
|
225
|
+
expect { generator.generate_command_line({names: bad_value}) }.to raise_error(ArgumentError, /must.*String or Array.*got.*#{bad_value.class}/)
|
226
|
+
end
|
227
|
+
|
228
|
+
it 'only accepts a string or array as an options value' do
|
229
|
+
expect { generator.generate_command_line({options: 'foo'}) }.to_not raise_error
|
230
|
+
expect { generator.generate_command_line({options: ['foo', 'bar']}) }.to_not raise_error
|
231
|
+
expect { generator.generate_command_line({options: bad_value}) }.to raise_error(ArgumentError, /must.*String or Array.*got.*#{bad_value.class}/)
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
describe 'old bugs' do
|
236
|
+
# Was doing an existence check instead of a true/false check
|
237
|
+
it 'will not set no_source flag when value is false' do
|
238
|
+
options = {no_source: false}
|
239
|
+
expect(generator.generate_command_line(options)).to eq('cucumber')
|
240
|
+
end
|
241
|
+
|
242
|
+
# Was doing an existence check instead of a true/false check
|
243
|
+
it 'will not set no_color flag when value is false' do
|
244
|
+
options = {no_color: false}
|
245
|
+
expect(generator.generate_command_line(options)).to eq('cucumber')
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
|
4
|
+
describe 'CukeCommander, Unit' do
|
5
|
+
|
6
|
+
let(:nodule) { CukeCommander }
|
7
|
+
|
8
|
+
|
9
|
+
it 'is defined' do
|
10
|
+
expect(Kernel.const_defined?(:CukeCommander)).to be true
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'defines the available Cucumber options' do
|
14
|
+
expect(nodule.const_defined?(:CUKE_OPTIONS)).to be true
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,164 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cuke_commander
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Eric Kessler
|
9
|
+
- Donavan Stanley
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2015-03-20 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: bundler
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ~>
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '1.6'
|
23
|
+
type: :development
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ~>
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '1.6'
|
31
|
+
- !ruby/object:Gem::Dependency
|
32
|
+
name: rake
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
type: :development
|
40
|
+
prerelease: false
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: cucumber
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: rspec
|
65
|
+
requirement: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ! '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
type: :development
|
72
|
+
prerelease: false
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
- !ruby/object:Gem::Dependency
|
80
|
+
name: simplecov
|
81
|
+
requirement: !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
83
|
+
requirements:
|
84
|
+
- - ! '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
type: :development
|
88
|
+
prerelease: false
|
89
|
+
version_requirements: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ! '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
description: Command Cucumber
|
96
|
+
email:
|
97
|
+
- morrow748@gmail.com
|
98
|
+
- stanleyd@grangeinsurance.com
|
99
|
+
executables: []
|
100
|
+
extensions: []
|
101
|
+
extra_rdoc_files: []
|
102
|
+
files:
|
103
|
+
- .gitignore
|
104
|
+
- .simplecov
|
105
|
+
- Gemfile
|
106
|
+
- LICENSE.txt
|
107
|
+
- README.md
|
108
|
+
- Rakefile
|
109
|
+
- cuke_commander.gemspec
|
110
|
+
- features/command_line_format.feature
|
111
|
+
- features/cucumber_options.feature
|
112
|
+
- features/generate_command_line.feature
|
113
|
+
- features/step_definitions/action_steps.rb
|
114
|
+
- features/step_definitions/setup_steps.rb
|
115
|
+
- features/step_definitions/verification_steps.rb
|
116
|
+
- features/support/env.rb
|
117
|
+
- lib/cuke_commander.rb
|
118
|
+
- lib/cuke_commander/cl_generator.rb
|
119
|
+
- lib/cuke_commander/version.rb
|
120
|
+
- spec/cl_generator_spec.rb
|
121
|
+
- spec/cuke_commander_spec.rb
|
122
|
+
- spec/spec_helper.rb
|
123
|
+
homepage: https://github.com/grange-insurance/cuke_commander
|
124
|
+
licenses:
|
125
|
+
- MIT
|
126
|
+
post_install_message:
|
127
|
+
rdoc_options: []
|
128
|
+
require_paths:
|
129
|
+
- lib
|
130
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
131
|
+
none: false
|
132
|
+
requirements:
|
133
|
+
- - ! '>='
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: '0'
|
136
|
+
segments:
|
137
|
+
- 0
|
138
|
+
hash: 772110449
|
139
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
140
|
+
none: false
|
141
|
+
requirements:
|
142
|
+
- - ! '>='
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
segments:
|
146
|
+
- 0
|
147
|
+
hash: 772110449
|
148
|
+
requirements: []
|
149
|
+
rubyforge_project:
|
150
|
+
rubygems_version: 1.8.24
|
151
|
+
signing_key:
|
152
|
+
specification_version: 3
|
153
|
+
summary: Provides an easy way to build a cucumber commandline.
|
154
|
+
test_files:
|
155
|
+
- features/command_line_format.feature
|
156
|
+
- features/cucumber_options.feature
|
157
|
+
- features/generate_command_line.feature
|
158
|
+
- features/step_definitions/action_steps.rb
|
159
|
+
- features/step_definitions/setup_steps.rb
|
160
|
+
- features/step_definitions/verification_steps.rb
|
161
|
+
- features/support/env.rb
|
162
|
+
- spec/cl_generator_spec.rb
|
163
|
+
- spec/cuke_commander_spec.rb
|
164
|
+
- spec/spec_helper.rb
|