square-cucumber 0.3.12.2 → 0.3.93.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +117 -4
- data/Manifest.txt +11 -0
- data/Rakefile +1 -1
- data/config/hoe.rb +3 -2
- data/cucumber.yml +2 -2
- data/examples/i18n/ko/features/addition.feature +5 -5
- data/examples/i18n/ko/features/step_definitons/calculator_steps.rb +1 -1
- data/examples/i18n/no/features/step_definitons/kalkulator_steps.rb +1 -1
- data/examples/i18n/pt/features/adicao.feature +4 -4
- data/examples/self_test/features/support/env.rb +2 -1
- data/examples/sinatra/features/support/env.rb +7 -1
- data/examples/steps_library/features/step_definitions/steps_lib1.rb +8 -0
- data/examples/steps_library/features/step_definitions/steps_lib2.rb +8 -0
- data/examples/tickets/features/step_definitons/tickets_steps.rb +15 -0
- data/examples/tickets/features/table_diffing.feature +13 -0
- data/examples/watir/features/step_definitons/search_steps.rb +5 -1
- data/features/cucumber_cli_diff_disabled.feature +2 -1
- data/features/html_formatter/a.html +5 -7
- data/features/junit_formatter.feature +21 -14
- data/features/profiles.feature +99 -0
- data/features/rake_task.feature +28 -0
- data/features/step_definitions/cucumber_steps.rb +28 -15
- data/features/steps_formatter.feature +25 -0
- data/features/support/env.rb +9 -5
- data/features/table_diffing.feature +45 -0
- data/features/unicode_table.feature +35 -0
- data/features/work_in_progress.feature +1 -0
- data/gem_tasks/contributors.rake +4 -0
- data/lib/cucumber/ast/background.rb +1 -0
- data/lib/cucumber/ast/comment.rb +1 -0
- data/lib/cucumber/ast/examples.rb +1 -0
- data/lib/cucumber/ast/feature.rb +10 -0
- data/lib/cucumber/ast/features.rb +6 -1
- data/lib/cucumber/ast/outline_table.rb +4 -1
- data/lib/cucumber/ast/py_string.rb +1 -1
- data/lib/cucumber/ast/scenario.rb +1 -0
- data/lib/cucumber/ast/scenario_outline.rb +2 -0
- data/lib/cucumber/ast/step.rb +5 -1
- data/lib/cucumber/ast/step_collection.rb +1 -0
- data/lib/cucumber/ast/step_invocation.rb +1 -0
- data/lib/cucumber/ast/table.rb +306 -52
- data/lib/cucumber/ast/tags.rb +1 -0
- data/lib/cucumber/ast/visitor.rb +2 -1
- data/lib/cucumber/cli/configuration.rb +28 -278
- data/lib/cucumber/cli/drb_client.rb +3 -1
- data/lib/cucumber/cli/language_help_formatter.rb +9 -7
- data/lib/cucumber/cli/main.rb +16 -2
- data/lib/cucumber/cli/options.rb +370 -0
- data/lib/cucumber/cli/profile_loader.rb +65 -0
- data/lib/cucumber/core_ext/instance_exec.rb +8 -5
- data/lib/cucumber/feature_file.rb +7 -1
- data/lib/cucumber/filter.rb +2 -2
- data/lib/cucumber/formatter/ansicolor.rb +42 -9
- data/lib/cucumber/formatter/console.rb +1 -1
- data/lib/cucumber/formatter/html.rb +12 -10
- data/lib/cucumber/formatter/junit.rb +63 -26
- data/lib/cucumber/formatter/pretty.rb +20 -5
- data/lib/cucumber/formatter/progress.rb +1 -1
- data/lib/cucumber/formatter/steps.rb +49 -0
- data/lib/cucumber/languages.yml +6 -6
- data/lib/cucumber/parser/feature.rb +90 -63
- data/lib/cucumber/parser/feature.tt +28 -1
- data/lib/cucumber/parser/i18n/language.rb +12 -5
- data/lib/cucumber/parser/table.rb +25 -25
- data/lib/cucumber/rake/task.rb +9 -3
- data/lib/cucumber/step_definition.rb +1 -1
- data/lib/cucumber/step_match.rb +1 -1
- data/lib/cucumber/step_mother.rb +3 -1
- data/lib/cucumber/version.rb +2 -2
- data/lib/cucumber/webrat/table_locator.rb +66 -0
- data/rails_generators/cucumber/cucumber_generator.rb +5 -1
- data/rails_generators/cucumber/templates/cucumber +3 -2
- data/rails_generators/cucumber/templates/cucumber.rake +18 -6
- data/rails_generators/cucumber/templates/cucumber_environment.rb +7 -4
- data/rails_generators/cucumber/templates/env.rb +1 -0
- data/rails_generators/cucumber/templates/spork_env.rb +1 -0
- data/rails_generators/cucumber/templates/webrat_steps.rb +22 -0
- data/rails_generators/feature/templates/feature.erb +1 -1
- data/rails_generators/feature/templates/steps.erb +2 -8
- data/spec/cucumber/ast/table_spec.rb +169 -0
- data/spec/cucumber/cli/configuration_spec.rb +144 -101
- data/spec/cucumber/cli/main_spec.rb +14 -5
- data/spec/cucumber/cli/options_spec.rb +311 -0
- data/spec/cucumber/cli/profile_loader_spec.rb +10 -0
- data/spec/cucumber/core_ext/proc_spec.rb +16 -2
- data/spec/cucumber/formatter/html_spec.rb +18 -0
- data/spec/cucumber/formatter/progress_spec.rb +2 -2
- data/spec/cucumber/parser/table_parser_spec.rb +1 -1
- data/spec/spec.opts +3 -1
- metadata +18 -4
- data/lib/cucumber/webrat/mechanize_world.rb +0 -82
data/lib/cucumber/cli/main.rb
CHANGED
@@ -34,16 +34,20 @@ module Cucumber
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def execute!(step_mother)
|
37
|
+
trap_interrupt
|
37
38
|
if configuration.drb?
|
38
39
|
begin
|
39
40
|
return DRbClient.run(@args, @error_stream, @out_stream)
|
40
41
|
rescue DRbClientError => e
|
41
42
|
@error_stream.puts "WARNING: #{e.message} Running features locally:"
|
42
|
-
configuration.parse!(@args)
|
43
43
|
end
|
44
44
|
end
|
45
45
|
step_mother.options = configuration.options
|
46
46
|
|
47
|
+
# Feature files must be loaded before files are required.
|
48
|
+
# This is because i18n step methods are only aliased when
|
49
|
+
# features are loaded. If we swap the order, the requires
|
50
|
+
# will fail.
|
47
51
|
features = load_plain_text_features
|
48
52
|
require_files
|
49
53
|
enable_diffing
|
@@ -58,6 +62,9 @@ module Cucumber
|
|
58
62
|
step_mother.scenarios(:failed).any? ||
|
59
63
|
(configuration.strict? && step_mother.steps(:undefined).any?)
|
60
64
|
end
|
65
|
+
rescue ProfilesNotDefinedError, YmlLoadError, ProfileNotFound => e
|
66
|
+
@error_stream.puts e.message
|
67
|
+
true
|
61
68
|
end
|
62
69
|
|
63
70
|
def load_plain_text_features
|
@@ -128,7 +135,14 @@ module Cucumber
|
|
128
135
|
end
|
129
136
|
end
|
130
137
|
end
|
131
|
-
|
138
|
+
|
139
|
+
def trap_interrupt
|
140
|
+
trap('INT') do
|
141
|
+
exit!(1) if $cucumber_interrupted
|
142
|
+
$cucumber_interrupted = true
|
143
|
+
STDERR.puts "\nExiting... Interrupt again to exit immediately."
|
144
|
+
end
|
145
|
+
end
|
132
146
|
end
|
133
147
|
end
|
134
148
|
end
|
@@ -0,0 +1,370 @@
|
|
1
|
+
require 'cucumber/cli/profile_loader'
|
2
|
+
module Cucumber
|
3
|
+
module Cli
|
4
|
+
|
5
|
+
class Options
|
6
|
+
BUILTIN_FORMATS = {
|
7
|
+
'html' => ['Cucumber::Formatter::Html', 'Generates a nice looking HTML report.'],
|
8
|
+
'pretty' => ['Cucumber::Formatter::Pretty', 'Prints the feature as is - in colours.'],
|
9
|
+
'profile' => ['Cucumber::Formatter::Profile', 'Prints the 10 slowest steps at the end.'],
|
10
|
+
'progress' => ['Cucumber::Formatter::Progress', 'Prints one character per scenario.'],
|
11
|
+
'rerun' => ['Cucumber::Formatter::Rerun', 'Prints failing files with line numbers.'],
|
12
|
+
'usage' => ['Cucumber::Formatter::Usage', 'Prints where step definitions are used.'],
|
13
|
+
'junit' => ['Cucumber::Formatter::Junit', 'Generates a report similar to Ant+JUnit.'],
|
14
|
+
'tag_cloud' => ['Cucumber::Formatter::TagCloud', 'Prints a tag cloud of tag usage.'],
|
15
|
+
'steps' => ['Cucumber::Formatter::Steps', 'Prints location of step definitions.']
|
16
|
+
}
|
17
|
+
max = BUILTIN_FORMATS.keys.map{|s| s.length}.max
|
18
|
+
FORMAT_HELP = (BUILTIN_FORMATS.keys.sort.map do |key|
|
19
|
+
" #{key}#{' ' * (max - key.length)} : #{BUILTIN_FORMATS[key][1]}"
|
20
|
+
end) + ["FORMAT can also be the fully qualified class name of",
|
21
|
+
"your own custom formatter. If the class isn't loaded,",
|
22
|
+
"Cucumber will attempt to require a file with a relative",
|
23
|
+
"file name that is the underscore name of the class name.",
|
24
|
+
"Example: --format Foo::BarZap -> Cucumber will look for",
|
25
|
+
"foo/bar_zap.rb. You can place the file with this relative",
|
26
|
+
"path underneath your features/support directory or anywhere",
|
27
|
+
"on Ruby's LOAD_PATH, for example in a Ruby gem."
|
28
|
+
]
|
29
|
+
DRB_FLAG = '--drb'
|
30
|
+
PROFILE_SHORT_FLAG = '-p'
|
31
|
+
PROFILE_LONG_FLAG = '--profile'
|
32
|
+
|
33
|
+
attr_reader :paths
|
34
|
+
|
35
|
+
def self.parse(args, out_stream, error_stream, options = {})
|
36
|
+
new(out_stream, error_stream, options).parse!(args)
|
37
|
+
end
|
38
|
+
|
39
|
+
def initialize(out_stream = STDOUT, error_stream = STDERR, options = {})
|
40
|
+
@out_stream = out_stream
|
41
|
+
@error_stream = error_stream
|
42
|
+
|
43
|
+
@default_profile = options[:default_profile]
|
44
|
+
@skip_profile_information = options[:skip_profile_information]
|
45
|
+
@profiles = []
|
46
|
+
@overridden_paths = []
|
47
|
+
@options = default_options
|
48
|
+
end
|
49
|
+
|
50
|
+
def [](key)
|
51
|
+
@options[key]
|
52
|
+
end
|
53
|
+
|
54
|
+
def []=(key, value)
|
55
|
+
@options[key] = value
|
56
|
+
end
|
57
|
+
|
58
|
+
def expanded_args_without_drb
|
59
|
+
@expanded_args_without_drb ||= (
|
60
|
+
previous_flag_was_profile = false
|
61
|
+
@expanded_args.reject do |arg|
|
62
|
+
if previous_flag_was_profile
|
63
|
+
previous_flag_was_profile = false
|
64
|
+
next true
|
65
|
+
end
|
66
|
+
if [PROFILE_SHORT_FLAG, PROFILE_LONG_FLAG].include?(arg)
|
67
|
+
previous_flag_was_profile = true
|
68
|
+
next true
|
69
|
+
end
|
70
|
+
arg == DRB_FLAG || @overridden_paths.include?(arg)
|
71
|
+
end
|
72
|
+
)
|
73
|
+
end
|
74
|
+
|
75
|
+
def parse!(args)
|
76
|
+
@args = args
|
77
|
+
@expanded_args = @args.dup
|
78
|
+
|
79
|
+
@args.extend(::OptionParser::Arguable)
|
80
|
+
|
81
|
+
@args.options do |opts|
|
82
|
+
opts.banner = ["Usage: cucumber [options] [ [FILE|DIR|URL][:LINE[:LINE]*] ]+", "",
|
83
|
+
"Examples:",
|
84
|
+
"cucumber examples/i18n/en/features",
|
85
|
+
"cucumber --language it examples/i18n/it/features/somma.feature:6:98:113",
|
86
|
+
"cucumber -s -i http://rubyurl.com/eeCl", "", "",
|
87
|
+
].join("\n")
|
88
|
+
opts.on("-r LIBRARY|DIR", "--require LIBRARY|DIR",
|
89
|
+
"Require files before executing the features. If this",
|
90
|
+
"option is not specified, all *.rb files that are",
|
91
|
+
"siblings or below the features will be loaded auto-",
|
92
|
+
"matically. Automatic loading is disabled when this",
|
93
|
+
"option is specified, and all loading becomes explicit.",
|
94
|
+
"Files under directories named \"support\" are always",
|
95
|
+
"loaded first.",
|
96
|
+
"This option can be specified multiple times.") do |v|
|
97
|
+
@options[:require] << v
|
98
|
+
end
|
99
|
+
opts.on("-l LANG", "--language LANG",
|
100
|
+
"Specify language for features (Default: #{@options[:lang]})",
|
101
|
+
%{Run with "--language help" to see all languages},
|
102
|
+
%{Run with "--language LANG help" to list keywords for LANG}) do |v|
|
103
|
+
if v == 'help'
|
104
|
+
list_languages_and_exit
|
105
|
+
elsif args==['help'] # I think this conditional is just cruft and can be removed
|
106
|
+
list_keywords_and_exit(v)
|
107
|
+
else
|
108
|
+
@options[:lang] = v
|
109
|
+
end
|
110
|
+
end
|
111
|
+
opts.on("-f FORMAT", "--format FORMAT",
|
112
|
+
"How to format features (Default: pretty). Available formats:",
|
113
|
+
*FORMAT_HELP) do |v|
|
114
|
+
@options[:formats] << [v, @out_stream]
|
115
|
+
end
|
116
|
+
opts.on("-o", "--out [FILE|DIR]",
|
117
|
+
"Write output to a file/directory instead of STDOUT. This option",
|
118
|
+
"applies to the previously specified --format, or the",
|
119
|
+
"default format if no format is specified. Check the specific",
|
120
|
+
"formatter's docs to see whether to pass a file or a dir.") do |v|
|
121
|
+
@options[:formats] << ['pretty', nil] if @options[:formats].empty?
|
122
|
+
@options[:formats][-1][1] = v
|
123
|
+
end
|
124
|
+
opts.on("-t TAGS", "--tags TAGS",
|
125
|
+
"Only execute the features or scenarios with the specified tags.",
|
126
|
+
"TAGS must be comma-separated without spaces. Prefix tags with ~ to",
|
127
|
+
"exclude features or scenarios having that tag. Tags can be specified",
|
128
|
+
"with or without the @ prefix.") do |v|
|
129
|
+
include_tags, exclude_tags = *parse_tags(v)
|
130
|
+
@options[:include_tags] += include_tags
|
131
|
+
@options[:exclude_tags] += exclude_tags
|
132
|
+
end
|
133
|
+
opts.on("-n NAME", "--name NAME",
|
134
|
+
"Only execute the feature elements which match part of the given name.",
|
135
|
+
"If this option is given more than once, it will match against all the",
|
136
|
+
"given names.") do |v|
|
137
|
+
@options[:name_regexps] << /#{v}/
|
138
|
+
end
|
139
|
+
opts.on("-e", "--exclude PATTERN", "Don't run feature files or require ruby files matching PATTERN") do |v|
|
140
|
+
@options[:excludes] << Regexp.new(v)
|
141
|
+
end
|
142
|
+
opts.on(PROFILE_SHORT_FLAG, "#{PROFILE_LONG_FLAG} PROFILE",
|
143
|
+
"Pull commandline arguments from cucumber.yml which can be defined as",
|
144
|
+
"strings or arrays. When a 'default' profile is defined and no profile",
|
145
|
+
"is specified it is always used. (Unless disabled, see -P below.)",
|
146
|
+
"When feature files are defined in a profile and on the command line",
|
147
|
+
"then only the ones from the command line are used.") do |v|
|
148
|
+
@profiles << v
|
149
|
+
end
|
150
|
+
opts.on('-P', '--no-profile',
|
151
|
+
"Disables all profile laoding to avoid using the 'default' profile.") do |v|
|
152
|
+
@disable_profile_loading = true
|
153
|
+
end
|
154
|
+
opts.on("-c", "--[no-]color",
|
155
|
+
"Whether or not to use ANSI color in the output. Cucumber decides",
|
156
|
+
"based on your platform and the output destination if not specified.") do |v|
|
157
|
+
Term::ANSIColor.coloring = v
|
158
|
+
end
|
159
|
+
opts.on("-d", "--dry-run", "Invokes formatters without executing the steps.",
|
160
|
+
"This also omits the loading of your support/env.rb file if it exists.",
|
161
|
+
"Implies --quiet.") do
|
162
|
+
@options[:dry_run] = true
|
163
|
+
@quiet = true
|
164
|
+
end
|
165
|
+
opts.on("-a", "--autoformat DIRECTORY",
|
166
|
+
"Reformats (pretty prints) feature files and write them to DIRECTORY.",
|
167
|
+
"Be careful if you choose to overwrite the originals.",
|
168
|
+
"Implies --dry-run --formatter pretty.") do |directory|
|
169
|
+
@options[:autoformat] = directory
|
170
|
+
Term::ANSIColor.coloring = false
|
171
|
+
@options[:dry_run] = true
|
172
|
+
@quiet = true
|
173
|
+
end
|
174
|
+
opts.on("-m", "--no-multiline",
|
175
|
+
"Don't print multiline strings and tables under steps.") do
|
176
|
+
@options[:no_multiline] = true
|
177
|
+
end
|
178
|
+
opts.on("-s", "--no-source",
|
179
|
+
"Don't print the file and line of the step definition with the steps.") do
|
180
|
+
@options[:source] = false
|
181
|
+
end
|
182
|
+
opts.on("-i", "--no-snippets", "Don't print snippets for pending steps.") do
|
183
|
+
@options[:snippets] = false
|
184
|
+
end
|
185
|
+
opts.on("-q", "--quiet", "Alias for --no-snippets --no-source.") do
|
186
|
+
@quiet = true
|
187
|
+
end
|
188
|
+
opts.on("-b", "--backtrace", "Show full backtrace for all errors.") do
|
189
|
+
Exception.cucumber_full_backtrace = true
|
190
|
+
end
|
191
|
+
opts.on("-S", "--strict", "Fail if there are any undefined steps.") do
|
192
|
+
@options[:strict] = true
|
193
|
+
end
|
194
|
+
opts.on("-w", "--wip", "Fail if there are any passing scenarios.") do
|
195
|
+
@options[:wip] = true
|
196
|
+
end
|
197
|
+
opts.on("-v", "--verbose", "Show the files and features loaded.") do
|
198
|
+
@options[:verbose] = true
|
199
|
+
end
|
200
|
+
opts.on("-g", "--guess", "Guess best match for Ambiguous steps.") do
|
201
|
+
@options[:guess] = true
|
202
|
+
end
|
203
|
+
opts.on("-x", "--expand", "Expand Scenario Outline Tables in output.") do
|
204
|
+
@options[:expand] = true
|
205
|
+
end
|
206
|
+
opts.on("--no-diff", "Disable diff output on failing expectations.") do
|
207
|
+
@options[:diff_enabled] = false
|
208
|
+
end
|
209
|
+
opts.on(DRB_FLAG, "Run features against a DRb server. (i.e. with the spork gem)") do
|
210
|
+
@options[:drb] = true
|
211
|
+
end
|
212
|
+
opts.on_tail("--version", "Show version.") do
|
213
|
+
@out_stream.puts VERSION::STRING
|
214
|
+
Kernel.exit
|
215
|
+
end
|
216
|
+
opts.on_tail("-h", "--help", "You're looking at it.") do
|
217
|
+
@out_stream.puts opts.help
|
218
|
+
Kernel.exit
|
219
|
+
end
|
220
|
+
end.parse!
|
221
|
+
|
222
|
+
if @quiet
|
223
|
+
@options[:snippets] = @options[:source] = false
|
224
|
+
else
|
225
|
+
@options[:snippets] = true if @options[:snippets].nil?
|
226
|
+
@options[:source] = true if @options[:source].nil?
|
227
|
+
end
|
228
|
+
|
229
|
+
|
230
|
+
extract_environment_variables
|
231
|
+
@options[:paths] = @args.dup #whatver is left over
|
232
|
+
|
233
|
+
merge_profiles
|
234
|
+
print_profile_information
|
235
|
+
|
236
|
+
self
|
237
|
+
end
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
protected
|
242
|
+
|
243
|
+
attr_reader :options, :profiles, :expanded_args
|
244
|
+
protected :options, :profiles, :expanded_args
|
245
|
+
|
246
|
+
def non_stdout_formats
|
247
|
+
@options[:formats].select {|format, output| output != @out_stream }
|
248
|
+
end
|
249
|
+
|
250
|
+
private
|
251
|
+
|
252
|
+
def extract_environment_variables
|
253
|
+
@args.delete_if do |arg|
|
254
|
+
if arg =~ /^(\w+)=(.*)$/
|
255
|
+
@options[:env_vars][$1] = $2
|
256
|
+
true
|
257
|
+
end
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
def parse_tags(tag_string)
|
262
|
+
tag_names = tag_string.split(",")
|
263
|
+
excludes, includes = tag_names.partition{|tag| tag =~ /^~/}
|
264
|
+
excludes = excludes.map{|tag| tag[1..-1]}
|
265
|
+
|
266
|
+
# Strip @
|
267
|
+
includes = includes.map{|tag| Ast::Tags.strip_prefix(tag)}
|
268
|
+
excludes = excludes.map{|tag| Ast::Tags.strip_prefix(tag)}
|
269
|
+
[includes, excludes]
|
270
|
+
end
|
271
|
+
|
272
|
+
def disable_profile_loading?
|
273
|
+
@disable_profile_loading
|
274
|
+
end
|
275
|
+
|
276
|
+
def merge_profiles
|
277
|
+
if @disable_profile_loading
|
278
|
+
@out_stream.puts "Disabling profiles..."
|
279
|
+
return
|
280
|
+
end
|
281
|
+
|
282
|
+
@profiles << @default_profile if default_profile_should_be_used?
|
283
|
+
|
284
|
+
@profiles.each do |profile|
|
285
|
+
profile_args = profile_loader.args_from(profile)
|
286
|
+
reverse_merge(
|
287
|
+
Options.parse(profile_args, @out_stream, @error_stream, :skip_profile_information => true)
|
288
|
+
)
|
289
|
+
end
|
290
|
+
|
291
|
+
end
|
292
|
+
|
293
|
+
def default_profile_should_be_used?
|
294
|
+
@profiles.empty? &&
|
295
|
+
profile_loader.cucumber_yml_defined? &&
|
296
|
+
profile_loader.has_profile?(@default_profile)
|
297
|
+
end
|
298
|
+
|
299
|
+
def profile_loader
|
300
|
+
@profile_loader ||= ProfileLoader.new
|
301
|
+
end
|
302
|
+
|
303
|
+
def reverse_merge(other_options)
|
304
|
+
@options = other_options.options.merge(@options)
|
305
|
+
@options[:require] += other_options[:require]
|
306
|
+
@options[:include_tags] += other_options[:include_tags]
|
307
|
+
@options[:exclude_tags] += other_options[:exclude_tags]
|
308
|
+
@options[:env_vars] = other_options[:env_vars].merge(@options[:env_vars])
|
309
|
+
if @options[:paths].empty?
|
310
|
+
@options[:paths] = other_options[:paths]
|
311
|
+
else
|
312
|
+
@overridden_paths += (other_options[:paths] - @options[:paths])
|
313
|
+
end
|
314
|
+
@options[:source] &= other_options[:source]
|
315
|
+
@options[:snippets] &= other_options[:snippets]
|
316
|
+
|
317
|
+
@profiles += other_options.profiles
|
318
|
+
@expanded_args += other_options.expanded_args
|
319
|
+
|
320
|
+
if @options[:formats].empty?
|
321
|
+
@options[:formats] = other_options[:formats]
|
322
|
+
else
|
323
|
+
@options[:formats] += other_options.non_stdout_formats
|
324
|
+
end
|
325
|
+
|
326
|
+
self
|
327
|
+
end
|
328
|
+
|
329
|
+
# TODO: Move to Language
|
330
|
+
def list_keywords_and_exit(lang)
|
331
|
+
unless Cucumber::LANGUAGES[lang]
|
332
|
+
raise("No language with key #{lang}")
|
333
|
+
end
|
334
|
+
LanguageHelpFormatter.list_keywords(@out_stream, lang)
|
335
|
+
Kernel.exit
|
336
|
+
end
|
337
|
+
|
338
|
+
def list_languages_and_exit
|
339
|
+
LanguageHelpFormatter.list_languages(@out_stream)
|
340
|
+
Kernel.exit
|
341
|
+
end
|
342
|
+
|
343
|
+
def print_profile_information
|
344
|
+
return if @skip_profile_information || @profiles.empty?
|
345
|
+
profiles_sentence = ''
|
346
|
+
profiles_sentence = @profiles.size == 1 ? @profiles.first :
|
347
|
+
"#{@profiles[0...-1].join(', ')} and #{@profiles.last}"
|
348
|
+
|
349
|
+
@out_stream.puts "Using the #{profiles_sentence} profile#{'s' if @profiles.size> 1}..."
|
350
|
+
end
|
351
|
+
|
352
|
+
def default_options
|
353
|
+
{
|
354
|
+
:strict => false,
|
355
|
+
:require => [],
|
356
|
+
:lang => nil,
|
357
|
+
:dry_run => false,
|
358
|
+
:formats => [],
|
359
|
+
:excludes => [],
|
360
|
+
:include_tags => [],
|
361
|
+
:exclude_tags => [],
|
362
|
+
:name_regexps => [],
|
363
|
+
:env_vars => {},
|
364
|
+
:diff_enabled => true
|
365
|
+
}
|
366
|
+
end
|
367
|
+
end
|
368
|
+
|
369
|
+
end
|
370
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module Cucumber
|
2
|
+
module Cli
|
3
|
+
|
4
|
+
class ProfileLoader
|
5
|
+
|
6
|
+
def args_from(profile)
|
7
|
+
unless cucumber_yml.has_key?(profile)
|
8
|
+
raise(ProfileNotFound, <<-END_OF_ERROR)
|
9
|
+
Could not find profile: '#{profile}'
|
10
|
+
|
11
|
+
Defined profiles in cucumber.yml:
|
12
|
+
* #{cucumber_yml.keys.join("\n * ")}
|
13
|
+
END_OF_ERROR
|
14
|
+
end
|
15
|
+
|
16
|
+
args_from_yml = cucumber_yml[profile] || ''
|
17
|
+
|
18
|
+
case(args_from_yml)
|
19
|
+
when String
|
20
|
+
raise YmlLoadError, "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*$/
|
21
|
+
args_from_yml = args_from_yml.split(' ')
|
22
|
+
when Array
|
23
|
+
raise YmlLoadError, "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?
|
24
|
+
else
|
25
|
+
raise YmlLoadError, "The '#{profile}' profile in cucumber.yml was a #{args_from_yml.class}. It must be a String or Array"
|
26
|
+
end
|
27
|
+
args_from_yml
|
28
|
+
end
|
29
|
+
|
30
|
+
def has_profile?(profile)
|
31
|
+
cucumber_yml.has_key?(profile)
|
32
|
+
end
|
33
|
+
|
34
|
+
def cucumber_yml_defined?
|
35
|
+
@defined ||= File.exist?('cucumber.yml')
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def cucumber_yml
|
41
|
+
return @cucumber_yml if @cucumber_yml
|
42
|
+
unless cucumber_yml_defined?
|
43
|
+
raise(ProfilesNotDefinedError,"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")
|
44
|
+
end
|
45
|
+
|
46
|
+
require 'yaml'
|
47
|
+
begin
|
48
|
+
@cucumber_yml = YAML::load(IO.read('cucumber.yml'))
|
49
|
+
rescue StandardError => e
|
50
|
+
raise(YmlLoadError,"cucumber.yml was found, but could not be parsed. Please refer to cucumber's documentation on correct profile usage.\n")
|
51
|
+
end
|
52
|
+
|
53
|
+
if @cucumber_yml.nil? || !@cucumber_yml.is_a?(Hash)
|
54
|
+
raise(YmlLoadError,"cucumber.yml was found, but was blank or malformed. Please refer to cucumber's documentation on correct profile usage.\n")
|
55
|
+
end
|
56
|
+
|
57
|
+
return @cucumber_yml
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|