cucumber 1.2.5 → 1.3.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.
- checksums.yaml +14 -6
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +1 -0
- data/.yardopts +1 -0
- data/CONTRIBUTING.md +2 -2
- data/History.md +38 -2
- data/bin/cucumber +2 -11
- data/cucumber.gemspec +3 -3
- data/cucumber.yml +5 -1
- data/examples/test_unit/Gemfile +4 -0
- data/examples/test_unit/features/step_definitions/test_unit_steps.rb +1 -4
- data/examples/watir/README.textile +2 -2
- data/examples/watir/features/support/env.rb +10 -7
- data/features/.cucumber/stepdefs.json +747 -1354
- data/features/assertions.feature +6 -2
- data/features/background.feature +3 -0
- data/features/backtraces.feature +3 -3
- data/features/before_hook.feature +43 -0
- data/features/bootstrap.feature +14 -2
- data/features/custom_formatter.feature +1 -1
- data/features/drb_server_integration.feature +3 -3
- data/features/formatter_callbacks.feature +2 -2
- data/features/formatter_step_file_colon_line.feature +1 -1
- data/features/html_formatter.feature +52 -1
- data/features/json_formatter.feature +93 -7
- data/features/load_path.feature +14 -0
- data/features/nested_steps.feature +75 -3
- data/features/nested_steps_i18n.feature +36 -0
- data/features/pretty_formatter.feature +31 -0
- data/features/progress_formatter.feature +31 -0
- data/features/raketask.feature +51 -0
- data/features/rerun_formatter.feature +1 -1
- data/features/stats_formatters.feature +17 -14
- data/features/step_definitions/cucumber_steps.rb +6 -4
- data/features/support/env.rb +31 -4
- data/features/support/feature_factory.rb +17 -0
- data/features/tagged_hooks.feature +37 -195
- data/features/transforms.feature +15 -15
- data/gem_tasks/cucumber.rake +2 -0
- data/gem_tasks/yard.rake +10 -6
- data/legacy_features/README.md +14 -0
- data/legacy_features/language_help.feature +3 -1
- data/legacy_features/report_called_undefined_steps.feature +1 -0
- data/legacy_features/snippets_when_using_star_keyword.feature +1 -0
- data/legacy_features/support/env.rb +4 -0
- data/lib/cucumber/ast/background.rb +35 -35
- data/lib/cucumber/ast/empty_background.rb +33 -0
- data/lib/cucumber/ast/examples.rb +5 -2
- data/lib/cucumber/ast/feature.rb +24 -35
- data/lib/cucumber/ast/features.rb +4 -1
- data/lib/cucumber/ast/has_steps.rb +9 -17
- data/lib/cucumber/ast/location.rb +41 -0
- data/lib/cucumber/ast/scenario.rb +37 -50
- data/lib/cucumber/ast/scenario_outline.rb +62 -49
- data/lib/cucumber/ast/step.rb +23 -27
- data/lib/cucumber/ast/step_collection.rb +16 -0
- data/lib/cucumber/ast/step_invocation.rb +4 -1
- data/lib/cucumber/ast/tree_walker.rb +7 -0
- data/lib/cucumber/cli/configuration.rb +15 -3
- data/lib/cucumber/cli/main.rb +24 -11
- data/lib/cucumber/cli/options.rb +24 -16
- data/lib/cucumber/configuration.rb +4 -0
- data/lib/cucumber/core_ext/disable_mini_and_test_unit_autorun.rb +10 -34
- data/lib/cucumber/core_ext/instance_exec.rb +4 -1
- data/lib/cucumber/core_ext/proc.rb +2 -0
- data/lib/cucumber/feature_file.rb +5 -12
- data/lib/cucumber/formatter/console.rb +10 -0
- data/lib/cucumber/formatter/gherkin_formatter_adapter.rb +4 -4
- data/lib/cucumber/formatter/html.rb +7 -42
- data/lib/cucumber/formatter/interceptor.rb +4 -0
- data/lib/cucumber/formatter/json_pretty.rb +0 -4
- data/lib/cucumber/formatter/junit.rb +8 -2
- data/lib/cucumber/formatter/pretty.rb +5 -1
- data/lib/cucumber/formatter/progress.rb +4 -0
- data/lib/cucumber/formatter/unicode.rb +12 -25
- data/lib/cucumber/formatter/usage.rb +7 -2
- data/lib/cucumber/js_support/js_snippets.rb +1 -1
- data/lib/cucumber/load_path.rb +13 -0
- data/lib/cucumber/parser/gherkin_builder.rb +237 -81
- data/lib/cucumber/platform.rb +1 -1
- data/lib/cucumber/py_support/py_language.rb +1 -1
- data/lib/cucumber/rake/task.rb +5 -1
- data/lib/cucumber/rb_support/rb_language.rb +20 -19
- data/lib/cucumber/rb_support/rb_world.rb +63 -21
- data/lib/cucumber/rb_support/snippet.rb +108 -0
- data/lib/cucumber/runtime.rb +1 -0
- data/lib/cucumber/runtime/support_code.rb +2 -2
- data/lib/cucumber/unit.rb +11 -0
- data/lib/cucumber/wire_support/wire_language.rb +1 -1
- data/spec/cucumber/ast/background_spec.rb +13 -6
- data/spec/cucumber/ast/feature_factory.rb +20 -10
- data/spec/cucumber/ast/features_spec.rb +51 -0
- data/spec/cucumber/ast/scenario_outline_spec.rb +13 -7
- data/spec/cucumber/ast/step_spec.rb +6 -4
- data/spec/cucumber/cli/configuration_spec.rb +34 -1
- data/spec/cucumber/cli/main_spec.rb +36 -26
- data/spec/cucumber/cli/options_spec.rb +28 -19
- data/spec/cucumber/core_ext/proc_spec.rb +13 -1
- data/spec/cucumber/formatter/interceptor_spec.rb +8 -0
- data/spec/cucumber/formatter/junit_spec.rb +33 -0
- data/spec/cucumber/formatter/pretty_spec.rb +391 -0
- data/spec/cucumber/rb_support/rb_language_spec.rb +21 -50
- data/spec/cucumber/rb_support/regexp_argument_matcher_spec.rb +2 -4
- data/spec/cucumber/rb_support/snippet_spec.rb +128 -0
- data/spec/cucumber/step_match_spec.rb +2 -6
- metadata +62 -113
- data/.rvmrc +0 -1
- data/features/hooks.feature +0 -59
- data/legacy_features/call_steps_from_stepdefs.feature +0 -154
|
@@ -9,6 +9,10 @@ module Cucumber
|
|
|
9
9
|
@steps.each{|step| step.step_collection = self}
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
+
def inspect
|
|
13
|
+
@steps.map { |s| [s.class, s.object_id] }.join(', ')
|
|
14
|
+
end
|
|
15
|
+
|
|
12
16
|
def accept(visitor)
|
|
13
17
|
return if Cucumber.wants_to_quit
|
|
14
18
|
@steps.each do |step|
|
|
@@ -24,10 +28,18 @@ module Cucumber
|
|
|
24
28
|
})
|
|
25
29
|
end
|
|
26
30
|
|
|
31
|
+
def skip_invoke!
|
|
32
|
+
@steps.each{|step_invocation| step_invocation.skip_invoke!}
|
|
33
|
+
end
|
|
34
|
+
|
|
27
35
|
def step_invocations_from_cells(cells)
|
|
28
36
|
@steps.map{|step| step.step_invocation_from_cells(cells)}
|
|
29
37
|
end
|
|
30
38
|
|
|
39
|
+
def +(step_invocations)
|
|
40
|
+
dup(step_invocations)
|
|
41
|
+
end
|
|
42
|
+
|
|
31
43
|
# Duplicates this instance and adds +step_invocations+ to the end
|
|
32
44
|
def dup(step_invocations = [])
|
|
33
45
|
StepCollection.new(@steps + step_invocations)
|
|
@@ -68,6 +80,10 @@ module Cucumber
|
|
|
68
80
|
:passed
|
|
69
81
|
end
|
|
70
82
|
|
|
83
|
+
def length
|
|
84
|
+
@steps.length
|
|
85
|
+
end
|
|
86
|
+
|
|
71
87
|
def to_sexp
|
|
72
88
|
@steps.map{|step| step.to_sexp}
|
|
73
89
|
end
|
|
@@ -107,6 +107,9 @@ module Cucumber
|
|
|
107
107
|
|
|
108
108
|
# This constant is appended to by Cuke4Duke. Do not change its name
|
|
109
109
|
BACKTRACE_FILTER_PATTERNS = [/vendor\/rails|lib\/cucumber|bin\/cucumber:|lib\/rspec|gems\/|minitest|test\/unit/]
|
|
110
|
+
if(Cucumber::JRUBY)
|
|
111
|
+
BACKTRACE_FILTER_PATTERNS << /org\/jruby/
|
|
112
|
+
end
|
|
110
113
|
PWD_PATTERN = /#{Regexp.escape(Dir.pwd)}\//m
|
|
111
114
|
|
|
112
115
|
# This is to work around double ":in " segments in JRuby backtraces. JRuby bug?
|
|
@@ -178,7 +181,7 @@ module Cucumber
|
|
|
178
181
|
end
|
|
179
182
|
|
|
180
183
|
def language
|
|
181
|
-
@step.language
|
|
184
|
+
@step.language || raise("Language is required on #{@step}")
|
|
182
185
|
end
|
|
183
186
|
|
|
184
187
|
def gherkin_statement
|
|
@@ -9,6 +9,13 @@ module Cucumber
|
|
|
9
9
|
@runtime, @listeners, @configuration = runtime, listeners, configuration
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
+
def execute(scenario, skip_hooks)
|
|
13
|
+
runtime.with_hooks(scenario, skip_hooks) do
|
|
14
|
+
scenario.skip_invoke! if scenario.failed?
|
|
15
|
+
visit_steps(scenario.steps)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
12
19
|
def visit_features(features)
|
|
13
20
|
broadcast(features) do
|
|
14
21
|
features.accept(self)
|
|
@@ -68,6 +68,10 @@ module Cucumber
|
|
|
68
68
|
@options[:dotcucumber]
|
|
69
69
|
end
|
|
70
70
|
|
|
71
|
+
def snippet_type
|
|
72
|
+
@options[:snippet_type] || :regexp
|
|
73
|
+
end
|
|
74
|
+
|
|
71
75
|
def build_tree_walker(runtime)
|
|
72
76
|
Ast::TreeWalker.new(runtime, formatters(runtime), self)
|
|
73
77
|
end
|
|
@@ -106,7 +110,7 @@ module Cucumber
|
|
|
106
110
|
end
|
|
107
111
|
|
|
108
112
|
def feature_files
|
|
109
|
-
potential_feature_files = paths.map do |path|
|
|
113
|
+
potential_feature_files = with_default_features_path(paths).map do |path|
|
|
110
114
|
path = path.gsub(/\\/, '/') # In case we're on windows. Globs don't work with backslashes.
|
|
111
115
|
path = path.chomp('/')
|
|
112
116
|
if File.directory?(path)
|
|
@@ -123,7 +127,9 @@ module Cucumber
|
|
|
123
127
|
end
|
|
124
128
|
|
|
125
129
|
def feature_dirs
|
|
126
|
-
paths.map { |f| File.directory?(f) ? f : File.dirname(f) }.uniq
|
|
130
|
+
dirs = paths.map { |f| File.directory?(f) ? f : File.dirname(f) }.uniq
|
|
131
|
+
dirs.delete('.') unless paths.include?('.')
|
|
132
|
+
with_default_features_path(dirs)
|
|
127
133
|
end
|
|
128
134
|
|
|
129
135
|
def log
|
|
@@ -152,9 +158,14 @@ module Cucumber
|
|
|
152
158
|
end
|
|
153
159
|
|
|
154
160
|
def paths
|
|
155
|
-
@options[:paths]
|
|
161
|
+
@options[:paths]
|
|
156
162
|
end
|
|
157
163
|
private
|
|
164
|
+
def with_default_features_path(paths)
|
|
165
|
+
return ['features'] if paths.empty?
|
|
166
|
+
paths
|
|
167
|
+
end
|
|
168
|
+
|
|
158
169
|
|
|
159
170
|
def formatters(runtime)
|
|
160
171
|
# TODO: We should remove the autoformat functionality. That
|
|
@@ -193,6 +204,7 @@ module Cucumber
|
|
|
193
204
|
def arrange_formats
|
|
194
205
|
@options[:formats] << ['pretty', @out_stream] if @options[:formats].empty?
|
|
195
206
|
@options[:formats] = @options[:formats].sort_by{|f| f[1] == @out_stream ? -1 : 1}
|
|
207
|
+
@options[:formats].uniq!
|
|
196
208
|
streams = @options[:formats].map { |(_, stream)| stream }
|
|
197
209
|
if streams != streams.uniq
|
|
198
210
|
raise "All but one formatter must use --out, only one can print to each stream (or STDOUT)"
|
data/lib/cucumber/cli/main.rb
CHANGED
|
@@ -21,11 +21,15 @@ module Cucumber
|
|
|
21
21
|
end
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
-
def initialize(args,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
def initialize(args, stdin=STDIN, out=STDOUT, err=STDERR, kernel=Kernel)
|
|
25
|
+
raise "args can't be nil" unless args
|
|
26
|
+
raise "out can't be nil" unless out
|
|
27
|
+
raise "err can't be nil" unless err
|
|
28
|
+
raise "kernel can't be nil" unless kernel
|
|
29
|
+
@args = args
|
|
30
|
+
@out = out
|
|
31
|
+
@err = err
|
|
32
|
+
@kernel = kernel
|
|
29
33
|
@configuration = nil
|
|
30
34
|
end
|
|
31
35
|
|
|
@@ -42,16 +46,25 @@ module Cucumber
|
|
|
42
46
|
|
|
43
47
|
runtime.run!
|
|
44
48
|
runtime.write_stepdefs_json
|
|
45
|
-
runtime.results.failure? || Cucumber.wants_to_quit
|
|
49
|
+
failure = runtime.results.failure? || Cucumber.wants_to_quit
|
|
50
|
+
@kernel.exit(failure ? 1 : 0)
|
|
46
51
|
rescue ProfilesNotDefinedError, YmlLoadError, ProfileNotFound => e
|
|
47
|
-
@
|
|
48
|
-
|
|
52
|
+
@err.puts(e.message)
|
|
53
|
+
rescue SystemExit => e
|
|
54
|
+
@kernel.exit(e.status)
|
|
55
|
+
rescue Errno::EACCES, Errno::ENOENT => e
|
|
56
|
+
@err.puts("#{e.message} (#{e.class})")
|
|
57
|
+
@kernel.exit(1)
|
|
58
|
+
rescue Exception => e
|
|
59
|
+
@err.puts("#{e.message} (#{e.class})")
|
|
60
|
+
@err.puts(e.backtrace.join("\n"))
|
|
61
|
+
@kernel.exit(1)
|
|
49
62
|
end
|
|
50
63
|
|
|
51
64
|
def configuration
|
|
52
65
|
return @configuration if @configuration
|
|
53
66
|
|
|
54
|
-
@configuration = Configuration.new(@
|
|
67
|
+
@configuration = Configuration.new(@out, @err)
|
|
55
68
|
@configuration.parse!(@args)
|
|
56
69
|
Cucumber.logger = @configuration.log
|
|
57
70
|
@configuration
|
|
@@ -61,10 +74,10 @@ module Cucumber
|
|
|
61
74
|
|
|
62
75
|
def run_drb_client
|
|
63
76
|
return false unless configuration.drb?
|
|
64
|
-
@drb_output = DRbClient.run(@args, @
|
|
77
|
+
@drb_output = DRbClient.run(@args, @err, @out, configuration.drb_port)
|
|
65
78
|
true
|
|
66
79
|
rescue DRbClientError => e
|
|
67
|
-
@
|
|
80
|
+
@err.puts "WARNING: #{e.message} Running features locally:"
|
|
68
81
|
end
|
|
69
82
|
|
|
70
83
|
def trap_interrupt
|
data/lib/cucumber/cli/options.rb
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
require 'cucumber/cli/profile_loader'
|
|
2
2
|
require 'cucumber/formatter/ansicolor'
|
|
3
|
+
require 'cucumber/rb_support/rb_language'
|
|
3
4
|
|
|
4
5
|
module Cucumber
|
|
5
6
|
module Cli
|
|
@@ -46,7 +47,8 @@ module Cucumber
|
|
|
46
47
|
OPTIONS_WITH_ARGS = ['-r', '--require', '--i18n', '-f', '--format', '-o', '--out',
|
|
47
48
|
'-t', '--tags', '-n', '--name', '-e', '--exclude',
|
|
48
49
|
PROFILE_SHORT_FLAG, PROFILE_LONG_FLAG,
|
|
49
|
-
'-a', '--autoformat', '-l', '--lines', '--port'
|
|
50
|
+
'-a', '--autoformat', '-l', '--lines', '--port',
|
|
51
|
+
'-I', '--snippet-type']
|
|
50
52
|
|
|
51
53
|
def self.parse(args, out_stream, error_stream, options = {})
|
|
52
54
|
new(out_stream, error_stream, options).parse!(args)
|
|
@@ -57,10 +59,11 @@ module Cucumber
|
|
|
57
59
|
@error_stream = error_stream
|
|
58
60
|
|
|
59
61
|
@default_profile = options[:default_profile]
|
|
60
|
-
@skip_profile_information = options[:skip_profile_information]
|
|
61
62
|
@profiles = []
|
|
62
63
|
@overridden_paths = []
|
|
63
64
|
@options = default_options
|
|
65
|
+
@profile_loader = options[:profile_loader]
|
|
66
|
+
@options[:skip_profile_information] = options[:skip_profile_information]
|
|
64
67
|
|
|
65
68
|
@quiet = @disable_profile_loading = nil
|
|
66
69
|
end
|
|
@@ -238,6 +241,12 @@ module Cucumber
|
|
|
238
241
|
opts.on("-i", "--no-snippets", "Don't print snippets for pending steps.") do
|
|
239
242
|
@options[:snippets] = false
|
|
240
243
|
end
|
|
244
|
+
opts.on("-I", "--snippet-type TYPE",
|
|
245
|
+
"Use different snippet type (Default: regexp). Available types:",
|
|
246
|
+
*Cucumber::RbSupport::RbLanguage.cli_snippet_type_options) do |v|
|
|
247
|
+
@options[:snippet_type] = v.to_sym
|
|
248
|
+
end
|
|
249
|
+
|
|
241
250
|
opts.on("-q", "--quiet", "Alias for --no-snippets --no-source.") do
|
|
242
251
|
@quiet = true
|
|
243
252
|
end
|
|
@@ -293,7 +302,6 @@ module Cucumber
|
|
|
293
302
|
@options[:paths] = @args.dup #whatver is left over
|
|
294
303
|
|
|
295
304
|
merge_profiles
|
|
296
|
-
print_profile_information
|
|
297
305
|
|
|
298
306
|
self
|
|
299
307
|
end
|
|
@@ -343,11 +351,20 @@ module Cucumber
|
|
|
343
351
|
@profiles << @default_profile if default_profile_should_be_used?
|
|
344
352
|
|
|
345
353
|
@profiles.each do |profile|
|
|
346
|
-
|
|
347
|
-
reverse_merge(
|
|
348
|
-
Options.parse(profile_args, @out_stream, @error_stream, :skip_profile_information => true)
|
|
349
|
-
)
|
|
354
|
+
merge_with_profile(profile)
|
|
350
355
|
end
|
|
356
|
+
|
|
357
|
+
@options[:profiles] = @profiles
|
|
358
|
+
end
|
|
359
|
+
|
|
360
|
+
def merge_with_profile(profile)
|
|
361
|
+
profile_args = profile_loader.args_from(profile)
|
|
362
|
+
profile_options = Options.parse(
|
|
363
|
+
profile_args, @out_stream, @error_stream,
|
|
364
|
+
:skip_profile_information => true,
|
|
365
|
+
:profile_loader => profile_loader
|
|
366
|
+
)
|
|
367
|
+
reverse_merge(profile_options)
|
|
351
368
|
end
|
|
352
369
|
|
|
353
370
|
def default_profile_should_be_used?
|
|
@@ -402,15 +419,6 @@ module Cucumber
|
|
|
402
419
|
Kernel.exit(0)
|
|
403
420
|
end
|
|
404
421
|
|
|
405
|
-
def print_profile_information
|
|
406
|
-
return if @skip_profile_information || @profiles.empty?
|
|
407
|
-
profiles_sentence = ''
|
|
408
|
-
profiles_sentence = @profiles.size == 1 ? @profiles.first :
|
|
409
|
-
"#{@profiles[0...-1].join(', ')} and #{@profiles.last}"
|
|
410
|
-
|
|
411
|
-
@out_stream.puts "Using the #{profiles_sentence} profile#{'s' if @profiles.size> 1}..."
|
|
412
|
-
end
|
|
413
|
-
|
|
414
422
|
def default_options
|
|
415
423
|
{
|
|
416
424
|
:strict => false,
|
|
@@ -1,39 +1,15 @@
|
|
|
1
|
-
# Why: http://groups.google.com/group/cukes/browse_thread/thread/5682d41436e235d7
|
|
2
|
-
begin
|
|
3
|
-
require 'minitest/unit'
|
|
4
|
-
# Don't attempt to monkeypatch if the require succeeded but didn't
|
|
5
|
-
# define the actual module.
|
|
6
|
-
#
|
|
7
|
-
# https://github.com/cucumber/cucumber/pull/93
|
|
8
|
-
# http://youtrack.jetbrains.net/issue/TW-17414
|
|
9
|
-
if defined?(MiniTest::Unit)
|
|
10
|
-
class MiniTest::Unit
|
|
11
|
-
class << self
|
|
12
|
-
@@installed_at_exit = true
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def run(*)
|
|
16
|
-
0
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
rescue LoadError => ignore
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
# Do the same for Test::Unit
|
|
24
1
|
begin
|
|
25
2
|
require 'test/unit'
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
end
|
|
3
|
+
|
|
4
|
+
if defined?(Test::Unit::AutoRunner.need_auto_run?)
|
|
5
|
+
# For test-unit gem >= 2.4.9
|
|
6
|
+
Test::Unit::AutoRunner.need_auto_run = false
|
|
7
|
+
elsif defined?(Test::Unit.run?)
|
|
8
|
+
# For test-unit gem < 2.4.9
|
|
9
|
+
Test::Unit.run = true
|
|
10
|
+
elsif defined?(Test::Unit::Runner)
|
|
11
|
+
# For test/unit bundled in Ruby >= 1.9.3
|
|
12
|
+
Test::Unit::Runner.module_eval("@@stop_auto_run = true")
|
|
37
13
|
end
|
|
38
14
|
rescue LoadError => ignore
|
|
39
15
|
end
|
|
@@ -87,8 +87,11 @@ class Object #:nodoc:
|
|
|
87
87
|
else
|
|
88
88
|
backtrace[replacement_line].gsub!(/`.*'/, "`#{pseudo_method}'") if pseudo_method
|
|
89
89
|
end
|
|
90
|
-
backtrace[replacement_line+1..-1] = nil
|
|
91
90
|
|
|
91
|
+
depth = backtrace.count { |line| line == instance_exec_invocation_line }
|
|
92
|
+
end_pos = depth > 1 ? instance_exec_pos : -1
|
|
93
|
+
|
|
94
|
+
backtrace[replacement_line+1..end_pos] = nil
|
|
92
95
|
backtrace.compact!
|
|
93
96
|
else
|
|
94
97
|
# This happens with rails, because they screw up the backtrace
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# Proc extension to get more location info out of a proc
|
|
2
|
+
require 'cucumber/platform'
|
|
2
3
|
class Proc #:nodoc:
|
|
3
4
|
PROC_PATTERN = /[\d\w]+@(.+):(\d+).*>/
|
|
4
5
|
PWD = Dir.pwd
|
|
@@ -16,6 +17,7 @@ class Proc #:nodoc:
|
|
|
16
17
|
path, line = *to_s.match(PROC_PATTERN)[1..2]
|
|
17
18
|
path = File.expand_path(path)
|
|
18
19
|
pwd = File.expand_path(PWD)
|
|
20
|
+
pwd.force_encoding(path.encoding) unless Cucumber::RUBY_1_8_7
|
|
19
21
|
if path.index(pwd)
|
|
20
22
|
path = path[pwd.length+1..-1]
|
|
21
23
|
elsif path =~ /.*\/gems\/(.*\.rb)$/
|
|
@@ -22,24 +22,21 @@ module Cucumber
|
|
|
22
22
|
end
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
-
# Parses a file and returns a Cucumber::Ast
|
|
25
|
+
# Parses a file and returns a Cucumber::Ast::Feature
|
|
26
26
|
# If +configuration_filters+ contains any filters, the result will
|
|
27
27
|
# be filtered.
|
|
28
28
|
def parse(configuration_filters, tag_counts)
|
|
29
29
|
filters = @lines || configuration_filters
|
|
30
30
|
|
|
31
|
-
builder = Cucumber::Parser::GherkinBuilder.new
|
|
31
|
+
builder = Cucumber::Parser::GherkinBuilder.new(@path)
|
|
32
32
|
filter_formatter = filters.empty? ? builder : Gherkin::Formatter::FilterFormatter.new(builder, filters)
|
|
33
33
|
tag_count_formatter = Gherkin::Formatter::TagCountFormatter.new(filter_formatter, tag_counts)
|
|
34
34
|
parser = Gherkin::Parser::Parser.new(tag_count_formatter, true, "root", false)
|
|
35
35
|
|
|
36
36
|
begin
|
|
37
37
|
parser.parse(source, @path, 0)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
ast.language = parser.i18n_language
|
|
41
|
-
ast.file = @path
|
|
42
|
-
ast
|
|
38
|
+
builder.language = parser.i18n_language
|
|
39
|
+
builder.result
|
|
43
40
|
rescue Gherkin::Lexer::LexingError, Gherkin::Parser::ParseError => e
|
|
44
41
|
e.message.insert(0, "#{@path}: ")
|
|
45
42
|
raise e
|
|
@@ -65,11 +62,7 @@ module Cucumber
|
|
|
65
62
|
raise e
|
|
66
63
|
rescue Errno::ENOENT => e
|
|
67
64
|
# special-case opening features, because this could be a new user:
|
|
68
|
-
|
|
69
|
-
STDERR.puts("You don't have a 'features' directory. Please create one to get started.",
|
|
70
|
-
"See http://cukes.info/ for more information.")
|
|
71
|
-
exit 1
|
|
72
|
-
end
|
|
65
|
+
e.message << ". Please create a #{@path} directory to get started."
|
|
73
66
|
raise e
|
|
74
67
|
end
|
|
75
68
|
end
|
|
@@ -192,6 +192,16 @@ module Cucumber
|
|
|
192
192
|
@delayed_messages = []
|
|
193
193
|
end
|
|
194
194
|
|
|
195
|
+
def print_profile_information
|
|
196
|
+
return if @options[:skip_profile_information] || @options[:profiles].nil? || @options[:profiles].empty?
|
|
197
|
+
profiles = @options[:profiles]
|
|
198
|
+
profiles_sentence = ''
|
|
199
|
+
profiles_sentence = profiles.size == 1 ? profiles.first :
|
|
200
|
+
"#{profiles[0...-1].join(', ')} and #{profiles.last}"
|
|
201
|
+
|
|
202
|
+
@io.puts "Using the #{profiles_sentence} profile#{'s' if profiles.size> 1}..."
|
|
203
|
+
end
|
|
204
|
+
|
|
195
205
|
private
|
|
196
206
|
|
|
197
207
|
FORMATS = Hash.new{ |hash, format| hash[format] = method(format).to_proc }
|
|
@@ -6,9 +6,9 @@ module Cucumber
|
|
|
6
6
|
# Adapts Cucumber formatter events to Gherkin formatter events
|
|
7
7
|
# This class will disappear when Cucumber is based on Gherkin's model.
|
|
8
8
|
class GherkinFormatterAdapter
|
|
9
|
-
def initialize(gherkin_formatter,
|
|
9
|
+
def initialize(gherkin_formatter, print_empty_match)
|
|
10
10
|
@gf = gherkin_formatter
|
|
11
|
-
@
|
|
11
|
+
@print_empty_match = print_empty_match
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def before_feature(feature)
|
|
@@ -36,7 +36,7 @@ module Cucumber
|
|
|
36
36
|
|
|
37
37
|
def before_step(step)
|
|
38
38
|
@gf.step(step.gherkin_statement)
|
|
39
|
-
if @
|
|
39
|
+
if @print_empty_match
|
|
40
40
|
if(@outline)
|
|
41
41
|
match = Gherkin::Formatter::Model::Match.new(step.gherkin_statement.outline_args, nil)
|
|
42
42
|
else
|
|
@@ -51,7 +51,7 @@ module Cucumber
|
|
|
51
51
|
arguments = step_match.step_arguments.map{|a| Gherkin::Formatter::Argument.new(a.offset, a.val)}
|
|
52
52
|
location = step_match.file_colon_line
|
|
53
53
|
match = Gherkin::Formatter::Model::Match.new(arguments, location)
|
|
54
|
-
if @
|
|
54
|
+
if @print_empty_match
|
|
55
55
|
# Trick the formatter to believe that's what was printed previously so we get arg highlights on #result
|
|
56
56
|
@gf.instance_variable_set('@match', match)
|
|
57
57
|
else
|