cucumber 0.3.92 → 0.3.93
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/History.txt +20 -1
- data/Manifest.txt +6 -0
- data/cucumber.yml +2 -2
- data/examples/i18n/pt/features/adicao.feature +4 -4
- data/features/profiles.feature +99 -0
- data/features/step_definitions/cucumber_steps.rb +20 -0
- data/features/work_in_progress.feature +1 -0
- data/lib/cucumber/cli/configuration.rb +23 -267
- data/lib/cucumber/cli/drb_client.rb +3 -1
- data/lib/cucumber/cli/main.rb +5 -7
- data/lib/cucumber/cli/options.rb +361 -0
- data/lib/cucumber/cli/profile_loader.rb +65 -0
- data/lib/cucumber/formatter/console.rb +1 -1
- data/lib/cucumber/formatter/html.rb +1 -0
- data/lib/cucumber/parser/feature.rb +67 -67
- data/lib/cucumber/parser/feature.tt +28 -1
- data/lib/cucumber/parser/i18n/language.rb +4 -0
- data/lib/cucumber/parser/table.rb +25 -25
- data/lib/cucumber/version.rb +1 -1
- data/lib/cucumber/webrat/table_locator.rb +1 -1
- data/rails_generators/cucumber/cucumber_generator.rb +5 -1
- data/rails_generators/cucumber/templates/cucumber +3 -2
- data/rails_generators/cucumber/templates/cucumber_environment.rb +7 -4
- data/rails_generators/cucumber/templates/webrat_steps.rb +4 -0
- data/spec/cucumber/cli/configuration_spec.rb +132 -102
- data/spec/cucumber/cli/main_spec.rb +14 -4
- data/spec/cucumber/cli/options_spec.rb +306 -0
- data/spec/cucumber/cli/profile_loader_spec.rb +10 -0
- data/spec/cucumber/formatter/html_spec.rb +18 -0
- data/spec/cucumber/parser/table_parser_spec.rb +1 -1
- data/spec/spec.opts +3 -1
- metadata +8 -2
data/History.txt
CHANGED
@@ -1,4 +1,19 @@
|
|
1
|
-
==
|
1
|
+
== 0.3.93 2009-08-03
|
2
|
+
|
3
|
+
Highlights in this release: Improved profile handling (cucumber.yml) and a fix for cucumber hanging.
|
4
|
+
|
5
|
+
=== New features
|
6
|
+
* script/generate cucumber --spork now sets up a spork gem dependency in the cucumber.rb environment. (Aslak Hellesøy)
|
7
|
+
* Feature files defined on the command line override any that are present in profiles. (#344 Ben Mabey)
|
8
|
+
* Default (STDOUT) formatter defined in profile can be overridden from the command line. (#344 Ben Mabey)
|
9
|
+
* Displays which profile, if any, is being used. (Ben Mabey)
|
10
|
+
* click_link_within(parent, link) webrat step (Joakim Kolsjö)
|
11
|
+
|
12
|
+
=== Bugfixes
|
13
|
+
* script/cucumber correctly loads the gem's binary if the plugin isn't installed.
|
14
|
+
* Cucumber hangs waiting for Ctrl+C if an Error is raised (#374 Aslak Hellesøy)
|
15
|
+
|
16
|
+
== 0.3.92 2009-07-29
|
2
17
|
|
3
18
|
This release has some minor improvements to the new Table.diff! functionality. For example,
|
4
19
|
if you're using Webrat and you want to compare a feature table with a HTML table containing
|
@@ -16,6 +31,9 @@ links in one of the columns, you can do:
|
|
16
31
|
* Upgrade Sinatra example to work with rack-test 0.3.0 and aslakhellesoy-webrat 0.4.4.1 (Aslak Hellesøy)
|
17
32
|
* require 'cucumber/webrat/table_locator' added to Spork environment for Rails (Anders Furseth)
|
18
33
|
|
34
|
+
=== Changed Features
|
35
|
+
* The 'default' profile is now ALWAYS used unless you specify another profile or use the -P or --no-profile flag. (#344 Ben Mabey)
|
36
|
+
|
19
37
|
== 0.3.91 2009-07-27
|
20
38
|
|
21
39
|
=== New Features
|
@@ -23,6 +41,7 @@ links in one of the columns, you can do:
|
|
23
41
|
* Run can be stopped programmatically by setting $cucumber_interrupted = true, for example in an After block. (Aslak Hellesøy)
|
24
42
|
* Table support for cuke4duke
|
25
43
|
|
44
|
+
|
26
45
|
== 0.3.90 2009-07-22
|
27
46
|
|
28
47
|
The Hot summer release
|
data/Manifest.txt
CHANGED
@@ -262,6 +262,7 @@ features/html_formatter/a.html
|
|
262
262
|
features/junit_formatter.feature
|
263
263
|
features/language_from_header.feature
|
264
264
|
features/multiline_names.feature
|
265
|
+
features/profiles.feature
|
265
266
|
features/rake_task.feature
|
266
267
|
features/report_called_undefined_steps.feature
|
267
268
|
features/snippet.feature
|
@@ -311,6 +312,8 @@ lib/cucumber/cli/configuration.rb
|
|
311
312
|
lib/cucumber/cli/drb_client.rb
|
312
313
|
lib/cucumber/cli/language_help_formatter.rb
|
313
314
|
lib/cucumber/cli/main.rb
|
315
|
+
lib/cucumber/cli/options.rb
|
316
|
+
lib/cucumber/cli/profile_loader.rb
|
314
317
|
lib/cucumber/core_ext/exception.rb
|
315
318
|
lib/cucumber/core_ext/instance_exec.rb
|
316
319
|
lib/cucumber/core_ext/proc.rb
|
@@ -382,11 +385,14 @@ spec/cucumber/broadcaster_spec.rb
|
|
382
385
|
spec/cucumber/cli/configuration_spec.rb
|
383
386
|
spec/cucumber/cli/drb_client_spec.rb
|
384
387
|
spec/cucumber/cli/main_spec.rb
|
388
|
+
spec/cucumber/cli/options_spec.rb
|
389
|
+
spec/cucumber/cli/profile_loader_spec.rb
|
385
390
|
spec/cucumber/core_ext/proc_spec.rb
|
386
391
|
spec/cucumber/core_ext/string_spec.rb
|
387
392
|
spec/cucumber/formatter/ansicolor_spec.rb
|
388
393
|
spec/cucumber/formatter/color_io_spec.rb
|
389
394
|
spec/cucumber/formatter/duration_spec.rb
|
395
|
+
spec/cucumber/formatter/html_spec.rb
|
390
396
|
spec/cucumber/formatter/progress_spec.rb
|
391
397
|
spec/cucumber/parser/feature_parser_spec.rb
|
392
398
|
spec/cucumber/parser/table_parser_spec.rb
|
data/cucumber.yml
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
default: --format progress
|
2
|
-
wip: --tags @
|
1
|
+
default: --format progress --tags ~@proposed,~@in-progress features
|
2
|
+
wip: --tags @in-progress --wip features
|
@@ -5,7 +5,7 @@ Funcionalidade: Adição
|
|
5
5
|
Eu quero saber como somar dois números
|
6
6
|
|
7
7
|
Cenário: Adicionar dois números
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
Dado que eu digitei 50 na calculadora
|
9
|
+
E que eu digitei 70 na calculadora
|
10
|
+
Quando eu aperto o botão de soma
|
11
|
+
Então o resultado na calculadora deve ser 120
|
@@ -0,0 +1,99 @@
|
|
1
|
+
Feature: Profiles
|
2
|
+
In order to save time and prevent carpal tunnel syndrome
|
3
|
+
Cucumber users can save and reuse commonly used cucumber flags in a 'cucumber.yml' file.
|
4
|
+
These named arguments are called profiles and the yml file should be in the root of your project.
|
5
|
+
Any cucumber argument is valid in a profile. To see all the available flags type 'cucumber --help'
|
6
|
+
For more information about profiles please see the wiki:
|
7
|
+
http://wiki.github.com/aslakhellesoy/cucumber/cucumberyml
|
8
|
+
|
9
|
+
Background: Basic App
|
10
|
+
Given a standard Cucumber project directory structure
|
11
|
+
And a file named "features/sample.feature" with:
|
12
|
+
"""
|
13
|
+
Feature: Sample
|
14
|
+
Scenario: this is a test
|
15
|
+
Given I am just testing stuff
|
16
|
+
"""
|
17
|
+
And a file named "features/support/env.rb"
|
18
|
+
And a file named "features/support/super_env.rb"
|
19
|
+
And the following profiles are defined:
|
20
|
+
"""
|
21
|
+
default: features/sample.feature --require features/support/env.rb -v
|
22
|
+
super: features/sample.feature --require features/support/super_env.rb -v
|
23
|
+
"""
|
24
|
+
|
25
|
+
Scenario: Explicitly defining a profile to run
|
26
|
+
When I run cucumber features/sample.feature --profile super
|
27
|
+
Then the output should contain
|
28
|
+
"""
|
29
|
+
Using the super profile...
|
30
|
+
"""
|
31
|
+
And exactly these files should be loaded: features/support/super_env.rb
|
32
|
+
|
33
|
+
Scenario: Defining multiple profiles to run
|
34
|
+
When I run cucumber features/sample.feature --profile default --profile super
|
35
|
+
Then the output should contain
|
36
|
+
"""
|
37
|
+
Using the default and super profiles...
|
38
|
+
"""
|
39
|
+
And exactly these files should be loaded: features/support/env.rb, features/support/super_env.rb
|
40
|
+
|
41
|
+
Scenario: Arguments passed in but no profile specified
|
42
|
+
When I run cucumber -v
|
43
|
+
Then the default profile should be used
|
44
|
+
And exactly these files should be loaded: features/support/env.rb
|
45
|
+
|
46
|
+
Scenario: Trying to use a missing profile
|
47
|
+
When I run cucumber -p foo
|
48
|
+
Then STDERR should be
|
49
|
+
"""
|
50
|
+
Could not find profile: 'foo'
|
51
|
+
|
52
|
+
Defined profiles in cucumber.yml:
|
53
|
+
* default
|
54
|
+
* super
|
55
|
+
|
56
|
+
"""
|
57
|
+
|
58
|
+
Scenario Outline: Disabling the default profile
|
59
|
+
When I run cucumber -v features/ <Flag>
|
60
|
+
Then the output should contain
|
61
|
+
"""
|
62
|
+
Disabling profiles...
|
63
|
+
"""
|
64
|
+
And exactly these files should be loaded: features/support/env.rb, features/support/super_env.rb
|
65
|
+
|
66
|
+
Examples:
|
67
|
+
| Flag |
|
68
|
+
| -P |
|
69
|
+
| --no-profile |
|
70
|
+
|
71
|
+
|
72
|
+
Scenario: Overriding the profile's features to run
|
73
|
+
Given a file named "features/another.feature" with:
|
74
|
+
"""
|
75
|
+
Feature: Just this one should be ran
|
76
|
+
"""
|
77
|
+
When I run cucumber -p default features/another.feature
|
78
|
+
Then exactly these features should be ran: features/another.feature
|
79
|
+
|
80
|
+
Scenario: Overriding the profile's formatter
|
81
|
+
You will most likely want to define a formatter in your default formatter.
|
82
|
+
However, you often want to run your features with a different formatter
|
83
|
+
yet still use the other the other arguments in the profile. Cucumber will
|
84
|
+
allow you to do this by giving precedence to the formatter specified on the
|
85
|
+
command line and override the one in the profile.
|
86
|
+
|
87
|
+
Given the following profiles are defined:
|
88
|
+
"""
|
89
|
+
default: features/sample.feature --require features/support/env.rb -v --format profile
|
90
|
+
"""
|
91
|
+
When I run cucumber features --format pretty
|
92
|
+
And the output should contain
|
93
|
+
"""
|
94
|
+
Feature: Sample
|
95
|
+
"""
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
@@ -111,6 +111,10 @@ Then /^STDERR should not match$/ do |text|
|
|
111
111
|
last_stderr.should_not =~ /#{text}/
|
112
112
|
end
|
113
113
|
|
114
|
+
Then /^STDERR should be$/ do |text|
|
115
|
+
last_stderr.should == text
|
116
|
+
end
|
117
|
+
|
114
118
|
Then /^STDERR should be empty$/ do
|
115
119
|
last_stderr.should == ""
|
116
120
|
end
|
@@ -128,3 +132,19 @@ Then /^"([^\"]*)" should be required$/ do |file_name|
|
|
128
132
|
last_stdout.should include("* #{file_name}")
|
129
133
|
end
|
130
134
|
|
135
|
+
Then /^exactly these files should be loaded:\s*(.*)$/ do |files|
|
136
|
+
last_stdout.scan(/^ \* (.*\.rb)$/).flatten.should == files.split(/,\s+/)
|
137
|
+
end
|
138
|
+
|
139
|
+
Then /^exactly these features should be ran:\s*(.*)$/ do |files|
|
140
|
+
last_stdout.scan(/^ \* (.*\.feature)$/).flatten.should == files.split(/,\s+/)
|
141
|
+
end
|
142
|
+
|
143
|
+
Then /^the (.*) profile should be used$/ do |profile|
|
144
|
+
last_stdout.should =~ /Using the #{profile} profile/
|
145
|
+
end
|
146
|
+
|
147
|
+
Then /^print output$/ do
|
148
|
+
puts last_stdout
|
149
|
+
end
|
150
|
+
|
@@ -1,6 +1,10 @@
|
|
1
|
+
require 'cucumber/cli/options'
|
2
|
+
|
1
3
|
module Cucumber
|
2
4
|
module Cli
|
3
5
|
class YmlLoadError < StandardError; end
|
6
|
+
class ProfilesNotDefinedError < YmlLoadError; end
|
7
|
+
class ProfileNotFound < StandardError; end
|
4
8
|
|
5
9
|
class Configuration
|
6
10
|
BUILTIN_FORMATS = {
|
@@ -14,187 +18,24 @@ module Cucumber
|
|
14
18
|
'tag_cloud' => 'Cucumber::Formatter::TagCloud',
|
15
19
|
'steps' => 'Cucumber::Formatter::Steps'
|
16
20
|
}
|
17
|
-
DRB_FLAG = '--drb'
|
18
|
-
PROFILE_SHORT_FLAG = '-p'
|
19
|
-
PROFILE_LONG_FLAG = '--profile'
|
20
21
|
|
21
|
-
attr_reader :paths
|
22
22
|
attr_reader :options
|
23
23
|
|
24
24
|
def initialize(out_stream = STDOUT, error_stream = STDERR)
|
25
25
|
@out_stream = out_stream
|
26
26
|
@error_stream = error_stream
|
27
|
-
|
28
|
-
@paths = []
|
29
|
-
@options = default_options
|
27
|
+
@options = Options.new(@out_stream, @error_stream, :default_profile => 'default')
|
30
28
|
end
|
31
29
|
|
32
30
|
def parse!(args)
|
33
|
-
args.concat(%w{--profile default}) if args.empty?
|
34
31
|
@args = args
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
@args.each do |arg|
|
39
|
-
if arg =~ /^(\w+)=(.*)$/
|
40
|
-
ENV[$1] = $2
|
41
|
-
@args.delete(arg)
|
42
|
-
end
|
43
|
-
end
|
32
|
+
@options.parse!(args)
|
33
|
+
raise("You can't use both --strict and --wip") if strict? && wip?
|
44
34
|
|
45
|
-
@args.
|
46
|
-
|
47
|
-
@args.options do |opts|
|
48
|
-
opts.banner = ["Usage: cucumber [options] [ [FILE|DIR|URL][:LINE[:LINE]*] ]+", "",
|
49
|
-
"Examples:",
|
50
|
-
"cucumber examples/i18n/en/features",
|
51
|
-
"cucumber --language it examples/i18n/it/features/somma.feature:6:98:113",
|
52
|
-
"cucumber -s -i http://rubyurl.com/eeCl", "", "",
|
53
|
-
].join("\n")
|
54
|
-
opts.on("-r LIBRARY|DIR", "--require LIBRARY|DIR",
|
55
|
-
"Require files before executing the features. If this",
|
56
|
-
"option is not specified, all *.rb files that are",
|
57
|
-
"siblings or below the features will be loaded auto-",
|
58
|
-
"matically. Automatic loading is disabled when this",
|
59
|
-
"option is specified, and all loading becomes explicit.",
|
60
|
-
"Files under directories named \"support\" are always",
|
61
|
-
"loaded first.",
|
62
|
-
"This option can be specified multiple times.") do |v|
|
63
|
-
@options[:require] ||= []
|
64
|
-
@options[:require] << v
|
65
|
-
end
|
66
|
-
opts.on("-l LANG", "--language LANG",
|
67
|
-
"Specify language for features (Default: #{@options[:lang]})",
|
68
|
-
%{Run with "--language help" to see all languages},
|
69
|
-
%{Run with "--language LANG help" to list keywords for LANG}) do |v|
|
70
|
-
if v == 'help'
|
71
|
-
list_languages_and_exit
|
72
|
-
elsif args==['help']
|
73
|
-
list_keywords_and_exit(v)
|
74
|
-
else
|
75
|
-
@options[:lang] = v
|
76
|
-
end
|
77
|
-
end
|
78
|
-
opts.on("-f FORMAT", "--format FORMAT",
|
79
|
-
"How to format features (Default: pretty)",
|
80
|
-
"Available formats: #{BUILTIN_FORMATS.keys.sort.join(", ")}",
|
81
|
-
"FORMAT can also be the fully qualified class name of",
|
82
|
-
"your own custom formatter. If the class isn't loaded,",
|
83
|
-
"Cucumber will attempt to require a file with a relative",
|
84
|
-
"file name that is the underscore name of the class name.",
|
85
|
-
"Example: --format Foo::BarZap -> Cucumber will look for",
|
86
|
-
"foo/bar_zap.rb. You can place the file with this relative",
|
87
|
-
"path underneath your features/support directory or anywhere",
|
88
|
-
"on Ruby's LOAD_PATH, for example in a Ruby gem.") do |v|
|
89
|
-
@options[:formats] << [v, @out_stream]
|
90
|
-
@active_format = v
|
91
|
-
end
|
92
|
-
opts.on("-o", "--out [FILE|DIR]",
|
93
|
-
"Write output to a file/directory instead of STDOUT. This option",
|
94
|
-
"applies to the previously specified --format, or the",
|
95
|
-
"default format if no format is specified. Check the specific",
|
96
|
-
"formatter's docs to see whether to pass a file or a dir.") do |v|
|
97
|
-
@options[:formats] << ['pretty', nil] if @options[:formats].empty?
|
98
|
-
@options[:formats][-1][1] = v
|
99
|
-
end
|
100
|
-
opts.on("-t TAGS", "--tags TAGS",
|
101
|
-
"Only execute the features or scenarios with the specified tags.",
|
102
|
-
"TAGS must be comma-separated without spaces. Prefix tags with ~ to",
|
103
|
-
"exclude features or scenarios having that tag. Tags can be specified",
|
104
|
-
"with or without the @ prefix.") do |v|
|
105
|
-
include_tags, exclude_tags = *parse_tags(v)
|
106
|
-
@options[:include_tags] += include_tags
|
107
|
-
@options[:exclude_tags] += exclude_tags
|
108
|
-
end
|
109
|
-
opts.on("-n NAME", "--name NAME",
|
110
|
-
"Only execute the feature elements which match part of the given name.",
|
111
|
-
"If this option is given more than once, it will match against all the",
|
112
|
-
"given names.") do |v|
|
113
|
-
@options[:name_regexps] << /#{v}/
|
114
|
-
end
|
115
|
-
opts.on("-e", "--exclude PATTERN", "Don't run feature files or require ruby files matching PATTERN") do |v|
|
116
|
-
@options[:excludes] << Regexp.new(v)
|
117
|
-
end
|
118
|
-
opts.on(PROFILE_SHORT_FLAG, "#{PROFILE_LONG_FLAG} PROFILE", "Pull commandline arguments from cucumber.yml.") do |v|
|
119
|
-
# Processing of this is done previsouly so that the DRb flag can be detected within profiles.
|
120
|
-
end
|
121
|
-
opts.on("-c", "--[no-]color",
|
122
|
-
"Whether or not to use ANSI color in the output. Cucumber decides",
|
123
|
-
"based on your platform and the output destination if not specified.") do |v|
|
124
|
-
Term::ANSIColor.coloring = v
|
125
|
-
end
|
126
|
-
opts.on("-d", "--dry-run", "Invokes formatters without executing the steps.",
|
127
|
-
"This also omits the loading of your support/env.rb file if it exists.",
|
128
|
-
"Implies --quiet.") do
|
129
|
-
@options[:dry_run] = true
|
130
|
-
@quiet = true
|
131
|
-
end
|
132
|
-
opts.on("-a", "--autoformat DIRECTORY",
|
133
|
-
"Reformats (pretty prints) feature files and write them to DIRECTORY.",
|
134
|
-
"Be careful if you choose to overwrite the originals.",
|
135
|
-
"Implies --dry-run --formatter pretty.") do |directory|
|
136
|
-
@options[:autoformat] = directory
|
137
|
-
Term::ANSIColor.coloring = false
|
138
|
-
@options[:dry_run] = true
|
139
|
-
@quiet = true
|
140
|
-
end
|
141
|
-
opts.on("-m", "--no-multiline",
|
142
|
-
"Don't print multiline strings and tables under steps.") do
|
143
|
-
@options[:no_multiline] = true
|
144
|
-
end
|
145
|
-
opts.on("-s", "--no-source",
|
146
|
-
"Don't print the file and line of the step definition with the steps.") do
|
147
|
-
@options[:source] = false
|
148
|
-
end
|
149
|
-
opts.on("-i", "--no-snippets", "Don't print snippets for pending steps.") do
|
150
|
-
@options[:snippets] = false
|
151
|
-
end
|
152
|
-
opts.on("-q", "--quiet", "Alias for --no-snippets --no-source.") do
|
153
|
-
@quiet = true
|
154
|
-
end
|
155
|
-
opts.on("-b", "--backtrace", "Show full backtrace for all errors.") do
|
156
|
-
Exception.cucumber_full_backtrace = true
|
157
|
-
end
|
158
|
-
opts.on("-S", "--strict", "Fail if there are any undefined steps.") do
|
159
|
-
@options[:strict] = true
|
160
|
-
end
|
161
|
-
opts.on("-w", "--wip", "Fail if there are any passing scenarios.") do
|
162
|
-
@options[:wip] = true
|
163
|
-
end
|
164
|
-
opts.on("-v", "--verbose", "Show the files and features loaded.") do
|
165
|
-
@options[:verbose] = true
|
166
|
-
end
|
167
|
-
opts.on("-g", "--guess", "Guess best match for Ambiguous steps.") do
|
168
|
-
@options[:guess] = true
|
169
|
-
end
|
170
|
-
opts.on("-x", "--expand", "Expand Scenario Outline Tables in output.") do
|
171
|
-
@options[:expand] = true
|
172
|
-
end
|
173
|
-
opts.on("--no-diff", "Disable diff output on failing expectations.") do
|
174
|
-
@options[:diff_enabled] = false
|
175
|
-
end
|
176
|
-
opts.on(DRB_FLAG, "Run features against a DRb server. (i.e. with the spork gem)") do
|
177
|
-
# Processing of this is done previsouly in order to short circuit args from being lost.
|
178
|
-
end
|
179
|
-
opts.on_tail("--version", "Show version.") do
|
180
|
-
@out_stream.puts VERSION::STRING
|
181
|
-
Kernel.exit
|
182
|
-
end
|
183
|
-
opts.on_tail("-h", "--help", "You're looking at it.") do
|
184
|
-
@out_stream.puts opts.help
|
185
|
-
Kernel.exit
|
186
|
-
end
|
187
|
-
end.parse!
|
35
|
+
return @args.replace(@options.expanded_args_without_drb) if drb?
|
188
36
|
|
37
|
+
set_environment_variables
|
189
38
|
arrange_formats
|
190
|
-
|
191
|
-
@options[:snippets] = true if !@quiet && @options[:snippets].nil?
|
192
|
-
@options[:source] = true if !@quiet && @options[:source].nil?
|
193
|
-
|
194
|
-
raise("You can't use both --strict and --wip") if @options[:strict] && @options[:wip]
|
195
|
-
|
196
|
-
# Whatever is left after option parsing is the FILE arguments
|
197
|
-
@paths += @args
|
198
39
|
end
|
199
40
|
|
200
41
|
def verbose?
|
@@ -218,18 +59,11 @@ module Cucumber
|
|
218
59
|
end
|
219
60
|
|
220
61
|
def drb?
|
221
|
-
@drb
|
62
|
+
@options[:drb]
|
222
63
|
end
|
223
64
|
|
224
|
-
def
|
225
|
-
|
226
|
-
excludes, includes = tag_names.partition{|tag| tag =~ /^~/}
|
227
|
-
excludes = excludes.map{|tag| tag[1..-1]}
|
228
|
-
|
229
|
-
# Strip @
|
230
|
-
includes = includes.map{|tag| Ast::Tags.strip_prefix(tag)}
|
231
|
-
excludes = excludes.map{|tag| Ast::Tags.strip_prefix(tag)}
|
232
|
-
[includes, excludes]
|
65
|
+
def paths
|
66
|
+
@options[:paths]
|
233
67
|
end
|
234
68
|
|
235
69
|
def build_formatter_broadcaster(step_mother)
|
@@ -270,7 +104,7 @@ module Cucumber
|
|
270
104
|
end
|
271
105
|
|
272
106
|
def files_to_require
|
273
|
-
requires = @options[:require]
|
107
|
+
requires = @options[:require].empty? ? require_dirs : @options[:require]
|
274
108
|
files = requires.map do |path|
|
275
109
|
path = path.gsub(/\\/, '/') # In case we're on windows. Globs don't work with backslashes.
|
276
110
|
path = path.gsub(/\/$/, '') # Strip trailing slash.
|
@@ -285,7 +119,7 @@ module Cucumber
|
|
285
119
|
end
|
286
120
|
|
287
121
|
def feature_files
|
288
|
-
potential_feature_files = @paths.map do |path|
|
122
|
+
potential_feature_files = @options[:paths].map do |path|
|
289
123
|
path = path.gsub(/\\/, '/') # In case we're on windows. Globs don't work with backslashes.
|
290
124
|
path = path.chomp('/')
|
291
125
|
File.directory?(path) ? Dir["#{path}/**/*.feature"] : path
|
@@ -294,7 +128,13 @@ module Cucumber
|
|
294
128
|
potential_feature_files
|
295
129
|
end
|
296
130
|
|
297
|
-
|
131
|
+
private
|
132
|
+
|
133
|
+
def set_environment_variables
|
134
|
+
@options[:env_vars].each do |var, value|
|
135
|
+
ENV[var] = value
|
136
|
+
end
|
137
|
+
end
|
298
138
|
|
299
139
|
def arrange_formats
|
300
140
|
@options[:formats] << ['pretty', @out_stream] if @options[:formats].empty?
|
@@ -309,11 +149,11 @@ module Cucumber
|
|
309
149
|
end
|
310
150
|
|
311
151
|
def feature_dirs
|
312
|
-
|
152
|
+
paths.map { |f| File.directory?(f) ? f : File.dirname(f) }.uniq
|
313
153
|
end
|
314
154
|
|
315
155
|
def require_dirs
|
316
|
-
feature_dirs+Dir['vendor/{gems,plugins}/*/cucumber']
|
156
|
+
feature_dirs + Dir['vendor/{gems,plugins}/*/cucumber']
|
317
157
|
end
|
318
158
|
|
319
159
|
def constantize(camel_cased_word)
|
@@ -341,90 +181,6 @@ module Cucumber
|
|
341
181
|
downcase
|
342
182
|
end
|
343
183
|
|
344
|
-
def expand_profiles_into_args
|
345
|
-
while (profile_index = @args.index(PROFILE_SHORT_FLAG) || @args.index(PROFILE_LONG_FLAG)) do
|
346
|
-
@args.delete_at(profile_index)
|
347
|
-
@args[profile_index] = args_from_profile(@args[profile_index])
|
348
|
-
@args.flatten!
|
349
|
-
end
|
350
|
-
end
|
351
|
-
|
352
|
-
def args_from_profile(profile)
|
353
|
-
unless cucumber_yml.has_key?(profile)
|
354
|
-
raise(<<-END_OF_ERROR)
|
355
|
-
Could not find profile: '#{profile}'
|
356
|
-
|
357
|
-
Defined profiles in cucumber.yml:
|
358
|
-
* #{cucumber_yml.keys.join("\n * ")}
|
359
|
-
END_OF_ERROR
|
360
|
-
end
|
361
|
-
|
362
|
-
args_from_yml = cucumber_yml[profile] || ''
|
363
|
-
|
364
|
-
case(args_from_yml)
|
365
|
-
when String
|
366
|
-
raise "The '#{profile}' profile in cucumber.yml was blank. Please define the command line arguments for the '#{profile}' profile in cucumber.yml.\n" if args_from_yml =~ /^\s*$/
|
367
|
-
args_from_yml = args_from_yml.split(' ')
|
368
|
-
when Array
|
369
|
-
raise "The '#{profile}' profile in cucumber.yml was empty. Please define the command line arguments for the '#{profile}' profile in cucumber.yml.\n" if args_from_yml.empty?
|
370
|
-
else
|
371
|
-
raise "The '#{profile}' profile in cucumber.yml was a #{args_from_yml.class}. It must be a String or Array"
|
372
|
-
end
|
373
|
-
args_from_yml
|
374
|
-
end
|
375
|
-
|
376
|
-
def cucumber_yml
|
377
|
-
return @cucumber_yml if @cucumber_yml
|
378
|
-
unless File.exist?('cucumber.yml')
|
379
|
-
raise(YmlLoadError,"cucumber.yml was not found. Please refer to cucumber's documentation on defining profiles in cucumber.yml. You must define a 'default' profile to use the cucumber command without any arguments.\nType 'cucumber --help' for usage.\n")
|
380
|
-
end
|
381
|
-
|
382
|
-
require 'yaml'
|
383
|
-
begin
|
384
|
-
@cucumber_yml = YAML::load(IO.read('cucumber.yml'))
|
385
|
-
rescue StandardError => e
|
386
|
-
raise(YmlLoadError,"cucumber.yml was found, but could not be parsed. Please refer to cucumber's documentation on correct profile usage.\n")
|
387
|
-
end
|
388
|
-
|
389
|
-
if @cucumber_yml.nil? || !@cucumber_yml.is_a?(Hash)
|
390
|
-
raise(YmlLoadError,"cucumber.yml was found, but was blank or malformed. Please refer to cucumber's documentation on correct profile usage.\n")
|
391
|
-
end
|
392
|
-
|
393
|
-
return @cucumber_yml
|
394
|
-
end
|
395
|
-
|
396
|
-
# TODO: Move to Language
|
397
|
-
def list_keywords_and_exit(lang)
|
398
|
-
unless Cucumber::LANGUAGES[lang]
|
399
|
-
raise("No language with key #{lang}")
|
400
|
-
end
|
401
|
-
LanguageHelpFormatter.list_keywords(@out_stream, lang)
|
402
|
-
Kernel.exit
|
403
|
-
end
|
404
|
-
|
405
|
-
def list_languages_and_exit
|
406
|
-
LanguageHelpFormatter.list_languages(@out_stream)
|
407
|
-
Kernel.exit
|
408
|
-
end
|
409
|
-
|
410
|
-
def parse_drb
|
411
|
-
@drb = @args.delete(DRB_FLAG) ? true : false
|
412
|
-
end
|
413
|
-
|
414
|
-
def default_options
|
415
|
-
{
|
416
|
-
:strict => false,
|
417
|
-
:require => nil,
|
418
|
-
:lang => nil,
|
419
|
-
:dry_run => false,
|
420
|
-
:formats => [],
|
421
|
-
:excludes => [],
|
422
|
-
:include_tags => [],
|
423
|
-
:exclude_tags => [],
|
424
|
-
:name_regexps => [],
|
425
|
-
:diff_enabled => true
|
426
|
-
}
|
427
|
-
end
|
428
184
|
end
|
429
185
|
|
430
186
|
end
|