cucumber 6.0.0 → 8.0.0.rc.1
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 +4 -4
- data/CHANGELOG.md +371 -168
- data/CONTRIBUTING.md +216 -55
- data/README.md +139 -21
- data/lib/autotest/cucumber_mixin.rb +5 -2
- data/lib/autotest/discover.rb +3 -2
- data/lib/cucumber/cli/configuration.rb +4 -1
- data/lib/cucumber/cli/main.rb +4 -3
- data/lib/cucumber/cli/options.rb +14 -4
- data/lib/cucumber/cli/profile_loader.rb +1 -5
- data/lib/cucumber/cli/rerun_file.rb +1 -1
- data/lib/cucumber/configuration.rb +5 -4
- data/lib/cucumber/constantize.rb +1 -1
- data/lib/cucumber/deprecate.rb +2 -1
- data/lib/cucumber/errors.rb +1 -1
- data/lib/cucumber/events/hook_test_step_created.rb +1 -2
- data/lib/cucumber/events/step_activated.rb +0 -6
- data/lib/cucumber/events/step_definition_registered.rb +0 -5
- data/lib/cucumber/events/test_case_created.rb +1 -2
- data/lib/cucumber/events/test_run_finished.rb +2 -1
- data/lib/cucumber/events/test_step_created.rb +1 -2
- data/lib/cucumber/events/undefined_parameter_type.rb +1 -2
- data/lib/cucumber/events.rb +2 -2
- data/lib/cucumber/file_specs.rb +2 -1
- data/lib/cucumber/filters/activate_steps.rb +1 -0
- data/lib/cucumber/filters/tag_limits/verifier.rb +1 -3
- data/lib/cucumber/filters/tag_limits.rb +1 -3
- data/lib/cucumber/formatter/ansicolor.rb +63 -70
- data/lib/cucumber/formatter/ast_lookup.rb +2 -2
- data/lib/cucumber/formatter/backtrace_filter.rb +1 -1
- data/lib/cucumber/formatter/console.rb +20 -4
- data/lib/cucumber/formatter/console_issues.rb +6 -1
- data/lib/cucumber/formatter/duration_extractor.rb +1 -0
- data/lib/cucumber/formatter/errors.rb +1 -0
- data/lib/cucumber/formatter/fanout.rb +1 -1
- data/lib/cucumber/formatter/http_io.rb +6 -1
- data/lib/cucumber/formatter/ignore_missing_messages.rb +1 -1
- data/lib/cucumber/formatter/io.rb +3 -1
- data/lib/cucumber/formatter/json.rb +32 -26
- data/lib/cucumber/formatter/junit.rb +6 -3
- data/lib/cucumber/formatter/message.rb +2 -1
- data/lib/cucumber/formatter/message_builder.rb +11 -10
- data/lib/cucumber/formatter/pretty.rb +34 -23
- data/lib/cucumber/formatter/progress.rb +1 -0
- data/lib/cucumber/formatter/publish_banner_printer.rb +1 -1
- data/lib/cucumber/formatter/query/hook_by_test_step.rb +1 -0
- data/lib/cucumber/formatter/query/test_case_started_by_test_case.rb +2 -0
- data/lib/cucumber/formatter/rerun.rb +2 -0
- data/lib/cucumber/formatter/steps.rb +5 -2
- data/lib/cucumber/formatter/summary.rb +1 -0
- data/lib/cucumber/formatter/unicode.rb +4 -4
- data/lib/cucumber/formatter/usage.rb +9 -7
- data/lib/cucumber/gherkin/data_table_parser.rb +2 -1
- data/lib/cucumber/gherkin/formatter/ansi_escapes.rb +2 -2
- data/lib/cucumber/gherkin/steps_parser.rb +1 -1
- data/lib/cucumber/glue/dsl.rb +19 -5
- data/lib/cucumber/glue/hook.rb +2 -1
- data/lib/cucumber/glue/invoke_in_world.rb +4 -4
- data/lib/cucumber/glue/proto_world.rb +12 -9
- data/lib/cucumber/glue/registry_and_more.rb +20 -5
- data/lib/cucumber/glue/registry_wrapper.rb +31 -0
- data/lib/cucumber/glue/step_definition.rb +9 -7
- data/lib/cucumber/hooks.rb +1 -0
- data/lib/cucumber/multiline_argument/data_table/diff_matrices.rb +2 -1
- data/lib/cucumber/multiline_argument/data_table.rb +58 -71
- data/lib/cucumber/platform.rb +2 -2
- data/lib/cucumber/rake/task.rb +10 -7
- data/lib/cucumber/rspec/disable_option_parser.rb +6 -3
- data/lib/cucumber/running_test_case.rb +1 -0
- data/lib/cucumber/runtime/meta_message_builder.rb +106 -0
- data/lib/cucumber/runtime/support_code.rb +3 -0
- data/lib/cucumber/runtime/user_interface.rb +5 -4
- data/lib/cucumber/runtime.rb +42 -23
- data/lib/cucumber/step_match.rb +6 -10
- data/lib/cucumber/step_match_search.rb +3 -2
- data/lib/cucumber/term/ansicolor.rb +74 -50
- data/lib/cucumber/term/banner.rb +1 -0
- data/lib/cucumber/version +1 -1
- data/lib/cucumber.rb +2 -1
- data/lib/simplecov_setup.rb +1 -1
- metadata +90 -89
- data/lib/cucumber/core_ext/string.rb +0 -11
@@ -1,9 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'cucumber/formatter/console'
|
4
|
+
|
3
5
|
module Cucumber
|
4
6
|
module Formatter
|
5
7
|
# The formatter used for <tt>--format steps</tt>
|
6
8
|
class Steps
|
9
|
+
include Console
|
7
10
|
def initialize(runtime, path_or_io, options)
|
8
11
|
@io = ensure_io(path_or_io, nil)
|
9
12
|
@options = options
|
@@ -24,8 +27,8 @@ module Cucumber
|
|
24
27
|
sources = @step_definition_files[step_definition_file]
|
25
28
|
source_indent = source_indent(sources)
|
26
29
|
sources.sort.each do |file_colon_line, regexp_source|
|
27
|
-
@io.print
|
28
|
-
@io.print " # #{file_colon_line}"
|
30
|
+
@io.print indent(regexp_source, 2)
|
31
|
+
@io.print indent(" # #{file_colon_line}", source_indent - regexp_source.unpack('U*').length)
|
29
32
|
@io.puts
|
30
33
|
end
|
31
34
|
@io.puts
|
@@ -17,7 +17,7 @@ if Cucumber::WINDOWS
|
|
17
17
|
end
|
18
18
|
else
|
19
19
|
Cucumber::CODEPAGE = 'cp1252'.freeze
|
20
|
-
|
20
|
+
$stderr.puts("WARNING: Couldn't detect your output codepage. Assuming it is 1252. You may have to chcp 1252 or SET CUCUMBER_OUTPUT_ENCODING=cp1252.")
|
21
21
|
end
|
22
22
|
|
23
23
|
module Cucumber
|
@@ -28,7 +28,7 @@ if Cucumber::WINDOWS
|
|
28
28
|
def cucumber_preprocess_output(*out)
|
29
29
|
out.map { |arg| arg.to_s.encode(Encoding.default_external) }
|
30
30
|
rescue Encoding::UndefinedConversionError => e
|
31
|
-
|
31
|
+
$stderr.cucumber_puts("WARNING: #{e.message}")
|
32
32
|
out
|
33
33
|
end
|
34
34
|
|
@@ -45,8 +45,8 @@ if Cucumber::WINDOWS
|
|
45
45
|
end
|
46
46
|
|
47
47
|
Kernel.extend(self)
|
48
|
-
|
49
|
-
|
48
|
+
$stdout.extend(self)
|
49
|
+
$stderr.extend(self)
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
@@ -2,10 +2,12 @@
|
|
2
2
|
|
3
3
|
require 'cucumber/formatter/progress'
|
4
4
|
require 'cucumber/step_definition_light'
|
5
|
+
require 'cucumber/formatter/console'
|
5
6
|
|
6
7
|
module Cucumber
|
7
8
|
module Formatter
|
8
9
|
class Usage < Progress
|
10
|
+
include Console
|
9
11
|
class StepDefKey < StepDefinitionLight
|
10
12
|
attr_accessor :mean_duration, :status
|
11
13
|
end
|
@@ -76,7 +78,7 @@ module Cucumber
|
|
76
78
|
if @stepdef_to_match[stepdef_key].any?
|
77
79
|
print_steps(stepdef_key)
|
78
80
|
else
|
79
|
-
@io.puts(
|
81
|
+
@io.puts(" #{format_string('NOT MATCHED BY ANY STEPS', :failed)}")
|
80
82
|
end
|
81
83
|
end
|
82
84
|
@io.puts
|
@@ -84,11 +86,11 @@ module Cucumber
|
|
84
86
|
end
|
85
87
|
|
86
88
|
def print_step_definition(stepdef_key)
|
87
|
-
@io.print format_string(format('%<duration>.7f', duration: stepdef_key.mean_duration), :skipped)
|
89
|
+
@io.print "#{format_string(format('%<duration>.7f', duration: stepdef_key.mean_duration), :skipped)} " unless config.dry_run?
|
88
90
|
@io.print format_string(stepdef_key.regexp_source, stepdef_key.status)
|
89
91
|
if config.source?
|
90
|
-
|
91
|
-
line_comment = " # #{stepdef_key.location}"
|
92
|
+
indent_amount = max_length - stepdef_key.regexp_source.unpack('U*').length
|
93
|
+
line_comment = indent(" # #{stepdef_key.location}", indent_amount)
|
92
94
|
@io.print(format_string(line_comment, :comment))
|
93
95
|
end
|
94
96
|
@io.puts
|
@@ -97,11 +99,11 @@ module Cucumber
|
|
97
99
|
def print_steps(stepdef_key)
|
98
100
|
@stepdef_to_match[stepdef_key].each do |step|
|
99
101
|
@io.print ' '
|
100
|
-
@io.print format_string(format('%<duration>.7f', duration: step[:duration]), :skipped)
|
102
|
+
@io.print "#{format_string(format('%<duration>.7f', duration: step[:duration]), :skipped)} " unless config.dry_run?
|
101
103
|
@io.print format_step(step[:keyword], step[:step_match], step[:status], nil)
|
102
104
|
if config.source?
|
103
|
-
|
104
|
-
line_comment = " # #{step[:location]}"
|
105
|
+
indent_amount = max_length - (step[:keyword].unpack('U*').length + step[:step_match].format_args.unpack('U*').length)
|
106
|
+
line_comment = indent(" # #{step[:location]}", indent_amount)
|
105
107
|
@io.print(format_string(line_comment, :comment))
|
106
108
|
end
|
107
109
|
@io.puts
|
@@ -15,10 +15,11 @@ module Cucumber
|
|
15
15
|
messages = ::Gherkin.from_source('dummy', feature_header + text, gherkin_options)
|
16
16
|
|
17
17
|
messages.each do |message|
|
18
|
-
gherkin_document = message.gherkin_document.
|
18
|
+
gherkin_document = message.gherkin_document.to_h unless message.gherkin_document.nil?
|
19
19
|
end
|
20
20
|
|
21
21
|
return if gherkin_document.nil?
|
22
|
+
|
22
23
|
gherkin_document[:feature][:children][0][:scenario][:steps][0][:data_table][:rows].each do |row|
|
23
24
|
@builder.row(row[:cells].map { |cell| cell[:value] })
|
24
25
|
end
|
@@ -54,7 +54,7 @@ module Cucumber
|
|
54
54
|
}.freeze
|
55
55
|
|
56
56
|
ALIASES = Hash.new do |h, k|
|
57
|
-
h[Regexp.last_match(1)]
|
57
|
+
"#{h[Regexp.last_match(1)]},bold" if k.to_s =~ /(.*)_arg/
|
58
58
|
end.merge(
|
59
59
|
'undefined' => 'yellow',
|
60
60
|
'pending' => 'yellow',
|
@@ -74,7 +74,7 @@ module Cucumber
|
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
|
-
ALIASES.
|
77
|
+
ALIASES.each_key do |key|
|
78
78
|
define_method(key) do
|
79
79
|
ALIASES[key].split(',').map { |color| COLORS[color] }.join('')
|
80
80
|
end
|
@@ -17,7 +17,7 @@ module Cucumber
|
|
17
17
|
messages = ::Gherkin.from_source('dummy', feature_header(dialect) + text, gherkin_options)
|
18
18
|
|
19
19
|
messages.each do |message|
|
20
|
-
gherkin_document = message.gherkin_document.
|
20
|
+
gherkin_document = message.gherkin_document.to_h unless message.gherkin_document.nil?
|
21
21
|
end
|
22
22
|
|
23
23
|
@builder.steps(gherkin_document[:feature][:children][0][:scenario][:steps])
|
data/lib/cucumber/glue/dsl.rb
CHANGED
@@ -107,10 +107,21 @@ module Cucumber
|
|
107
107
|
value.nil? ? default : value
|
108
108
|
end
|
109
109
|
|
110
|
-
# Registers a proc that will run after Cucumber is configured
|
111
|
-
|
112
|
-
|
113
|
-
|
110
|
+
# Registers a proc that will run after Cucumber is configured in order to install an external plugin.
|
111
|
+
def InstallPlugin(&proc)
|
112
|
+
Dsl.register_rb_hook('install_plugin', [], proc)
|
113
|
+
end
|
114
|
+
|
115
|
+
# Registers a proc that will run before the execution of the scenarios.
|
116
|
+
# Use it for your final set-ups
|
117
|
+
def BeforeAll(&proc)
|
118
|
+
Dsl.register_rb_hook('before_all', [], proc)
|
119
|
+
end
|
120
|
+
|
121
|
+
# Registers a proc that will run after the execution of the scenarios.
|
122
|
+
# Use it for your final clean-ups
|
123
|
+
def AfterAll(&proc)
|
124
|
+
Dsl.register_rb_hook('after_all', [], proc)
|
114
125
|
end
|
115
126
|
|
116
127
|
# Registers a new Ruby StepDefinition. This method is aliased
|
@@ -136,5 +147,8 @@ module Cucumber
|
|
136
147
|
end
|
137
148
|
end
|
138
149
|
|
139
|
-
#
|
150
|
+
# rubocop:disable Style/MixinUsage
|
151
|
+
# This "should" always be present, because it allows users to write `Before` and `After`
|
152
|
+
# See. https://github.com/cucumber/cucumber-ruby/pull/1566#discussion_r683235396
|
140
153
|
extend(Cucumber::Glue::Dsl)
|
154
|
+
# rubocop:enable Style/MixinUsage
|
data/lib/cucumber/glue/hook.rb
CHANGED
@@ -32,7 +32,7 @@ module Cucumber
|
|
32
32
|
Cucumber::Messages::Envelope.new(
|
33
33
|
hook: Cucumber::Messages::Hook.new(
|
34
34
|
id: id,
|
35
|
-
tag_expression: tag_expressions.join(' '),
|
35
|
+
tag_expression: tag_expressions.empty? ? nil : tag_expressions.join(' '),
|
36
36
|
source_reference: Cucumber::Messages::SourceReference.new(
|
37
37
|
uri: location.file,
|
38
38
|
location: Cucumber::Messages::Location.new(
|
@@ -58,6 +58,7 @@ module Cucumber
|
|
58
58
|
end
|
59
59
|
|
60
60
|
next unless tag_expression.include?(',')
|
61
|
+
|
61
62
|
warn("Found tagged hook with '#{tag_expression}'." \
|
62
63
|
"'@tag1,@tag2' is no longer supported, use '@tag or @tag2' instead.")
|
63
64
|
end
|
@@ -12,6 +12,7 @@ module Cucumber
|
|
12
12
|
|
13
13
|
instance_exec_pos = backtrace.index(instance_exec_invocation_line)
|
14
14
|
return unless instance_exec_pos
|
15
|
+
|
15
16
|
replacement_line = instance_exec_pos + INSTANCE_EXEC_OFFSET
|
16
17
|
backtrace[replacement_line].gsub!(/`.*'/, "`#{pseudo_method}'") if pseudo_method
|
17
18
|
|
@@ -27,7 +28,7 @@ module Cucumber
|
|
27
28
|
if check_arity && !cucumber_compatible_arity?(args, block)
|
28
29
|
world.instance_exec do
|
29
30
|
ari = block.arity
|
30
|
-
ari = ari < 0 ?
|
31
|
+
ari = ari < 0 ? "#{ari.abs - 1}+" : ari
|
31
32
|
s1 = ari == 1 ? '' : 's'
|
32
33
|
s2 = args.length == 1 ? '' : 's'
|
33
34
|
raise ArityMismatchError, "Your block takes #{ari} argument#{s1}, but the Regexp matched #{args.length} argument#{s2}."
|
@@ -40,9 +41,8 @@ module Cucumber
|
|
40
41
|
|
41
42
|
def self.cucumber_compatible_arity?(args, block)
|
42
43
|
return true if block.arity == args.length
|
43
|
-
if block.arity
|
44
|
-
|
45
|
-
end
|
44
|
+
return true if block.arity.negative? && args.length >= (block.arity.abs - 1)
|
45
|
+
|
46
46
|
false
|
47
47
|
end
|
48
48
|
|
@@ -95,6 +95,8 @@ module Cucumber
|
|
95
95
|
media_type = MIME::Types.type_for(file).first if media_type.nil?
|
96
96
|
|
97
97
|
super(content, media_type.to_s)
|
98
|
+
rescue StandardError
|
99
|
+
super
|
98
100
|
end
|
99
101
|
|
100
102
|
# Mark the matched step as pending.
|
@@ -136,8 +138,8 @@ module Cucumber
|
|
136
138
|
# TODO: pass these in when building the module, instead of mutating them later
|
137
139
|
# Extend the World with user-defined modules
|
138
140
|
def add_modules!(world_modules, namespaced_world_modules)
|
139
|
-
add_world_modules!(world_modules)
|
140
|
-
add_namespaced_modules!(namespaced_world_modules)
|
141
|
+
add_world_modules!(world_modules) if world_modules.any?
|
142
|
+
add_namespaced_modules!(namespaced_world_modules) if namespaced_world_modules.any?
|
141
143
|
end
|
142
144
|
|
143
145
|
define_method(:step) do |name, raw_multiline_arg = nil|
|
@@ -183,14 +185,13 @@ module Cucumber
|
|
183
185
|
modules.each do |namespace, world_modules|
|
184
186
|
world_modules.each do |world_module|
|
185
187
|
variable_name = "@__#{namespace}_world"
|
188
|
+
inner_world = instance_variable_get(variable_name) || Object.new
|
189
|
+
|
190
|
+
instance_variable_set(
|
191
|
+
variable_name,
|
192
|
+
inner_world.extend(world_module)
|
193
|
+
)
|
186
194
|
|
187
|
-
inner_world = if self.class.respond_to?(namespace)
|
188
|
-
instance_variable_get(variable_name)
|
189
|
-
else
|
190
|
-
Object.new
|
191
|
-
end
|
192
|
-
instance_variable_set(variable_name,
|
193
|
-
inner_world.extend(world_module))
|
194
195
|
self.class.send(:define_method, namespace) do
|
195
196
|
instance_variable_get(variable_name)
|
196
197
|
end
|
@@ -200,6 +201,8 @@ module Cucumber
|
|
200
201
|
|
201
202
|
# @private
|
202
203
|
def stringify_namespaced_modules
|
204
|
+
return '' if @__namespaced_modules.nil?
|
205
|
+
|
203
206
|
@__namespaced_modules.map { |k, v| "#{v.join(',')} (as #{k})" }.join('+')
|
204
207
|
end
|
205
208
|
end
|
@@ -4,6 +4,7 @@ require 'cucumber/cucumber_expressions/parameter_type_registry'
|
|
4
4
|
require 'cucumber/cucumber_expressions/cucumber_expression'
|
5
5
|
require 'cucumber/cucumber_expressions/regular_expression'
|
6
6
|
require 'cucumber/cucumber_expressions/cucumber_expression_generator'
|
7
|
+
require 'cucumber/deprecate'
|
7
8
|
require 'cucumber/glue/dsl'
|
8
9
|
require 'cucumber/glue/snippet'
|
9
10
|
require 'cucumber/glue/hook'
|
@@ -91,7 +92,7 @@ module Cucumber
|
|
91
92
|
step_definition
|
92
93
|
rescue Cucumber::CucumberExpressions::UndefinedParameterTypeError => e
|
93
94
|
# TODO: add a way to extract the parameter type directly from the error.
|
94
|
-
type_name = e.message.match(/^Undefined parameter type ['
|
95
|
+
type_name = e.message.match(/^Undefined parameter type ['|{](.*)['|}].?$/)[1]
|
95
96
|
|
96
97
|
@configuration.notify :undefined_parameter_type, type_name, string_or_regexp
|
97
98
|
end
|
@@ -99,6 +100,7 @@ module Cucumber
|
|
99
100
|
def build_rb_world_factory(world_modules, namespaced_world_modules, proc)
|
100
101
|
if proc
|
101
102
|
raise MultipleWorld.new(@world_proc, proc) if @world_proc
|
103
|
+
|
102
104
|
@world_proc = proc
|
103
105
|
end
|
104
106
|
@world_modules ||= []
|
@@ -134,9 +136,21 @@ module Cucumber
|
|
134
136
|
@current_world = nil
|
135
137
|
end
|
136
138
|
|
137
|
-
def
|
138
|
-
hooks[:
|
139
|
-
hook.invoke('
|
139
|
+
def install_plugin(configuration, registry)
|
140
|
+
hooks[:install_plugin].each do |hook|
|
141
|
+
hook.invoke('InstallPlugin', [configuration, registry])
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
def before_all
|
146
|
+
hooks[:before_all].each do |hook|
|
147
|
+
hook.invoke('BeforeAll', [])
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
def after_all
|
152
|
+
hooks[:after_all].each do |hook|
|
153
|
+
hook.invoke('AfterAll', [])
|
140
154
|
end
|
141
155
|
end
|
142
156
|
|
@@ -149,7 +163,7 @@ module Cucumber
|
|
149
163
|
@hooks = nil
|
150
164
|
end
|
151
165
|
|
152
|
-
def hooks_for(phase, scenario)
|
166
|
+
def hooks_for(phase, scenario) # :nodoc:
|
153
167
|
hooks[phase.to_sym].select { |hook| scenario.accept_hook?(hook) }
|
154
168
|
end
|
155
169
|
|
@@ -168,6 +182,7 @@ module Cucumber
|
|
168
182
|
def create_expression(string_or_regexp)
|
169
183
|
return CucumberExpressions::CucumberExpression.new(string_or_regexp, @parameter_type_registry) if string_or_regexp.is_a?(String)
|
170
184
|
return CucumberExpressions::RegularExpression.new(string_or_regexp, @parameter_type_registry) if string_or_regexp.is_a?(Regexp)
|
185
|
+
|
171
186
|
raise ArgumentError, 'Expression must be a String or Regexp'
|
172
187
|
end
|
173
188
|
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Cucumber
|
4
|
+
module Glue
|
5
|
+
##
|
6
|
+
# This class wraps some internals methods to expose them to external plugins.
|
7
|
+
class RegistryWrapper
|
8
|
+
def initialize(registry)
|
9
|
+
@registry = registry
|
10
|
+
end
|
11
|
+
|
12
|
+
##
|
13
|
+
# Creates a new CucumberExpression from the given +string_or_regexp+.
|
14
|
+
#
|
15
|
+
# If +string_or_regexp+ is a string, it will return a new CucumberExpression::CucumberExpression
|
16
|
+
#
|
17
|
+
# If +string_or_regexp+ is a regexp, it will return a new CucumberExpressions::RegularExpression
|
18
|
+
#
|
19
|
+
# An ArgumentError is raised if +string_or_regexp+ is not a string or a regexp
|
20
|
+
def create_expression(string_or_regexp)
|
21
|
+
@registry.create_expression(string_or_regexp)
|
22
|
+
end
|
23
|
+
|
24
|
+
##
|
25
|
+
# Return the current execution environment - AKA an isntance of World
|
26
|
+
def current_world
|
27
|
+
@registry.current_world
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'cucumber/step_match'
|
4
|
-
require 'cucumber/core_ext/string'
|
5
4
|
require 'cucumber/glue/invoke_in_world'
|
6
5
|
|
7
6
|
module Cucumber
|
@@ -26,6 +25,7 @@ module Cucumber
|
|
26
25
|
class << self
|
27
26
|
def new(id, registry, string_or_regexp, proc_or_sym, options)
|
28
27
|
raise MissingProc if proc_or_sym.nil?
|
28
|
+
|
29
29
|
super id, registry, registry.create_expression(string_or_regexp), create_proc(proc_or_sym, options)
|
30
30
|
end
|
31
31
|
|
@@ -34,6 +34,7 @@ module Cucumber
|
|
34
34
|
def create_proc(proc_or_sym, options)
|
35
35
|
return proc_or_sym if proc_or_sym.is_a?(Proc)
|
36
36
|
raise ArgumentError unless proc_or_sym.is_a?(Symbol)
|
37
|
+
|
37
38
|
message = proc_or_sym
|
38
39
|
target_proc = parse_target_proc_from(options)
|
39
40
|
patch_location_onto lambda { |*args|
|
@@ -50,6 +51,7 @@ module Cucumber
|
|
50
51
|
|
51
52
|
def parse_target_proc_from(options)
|
52
53
|
return -> { self } unless options.key?(:on)
|
54
|
+
|
53
55
|
target = options[:on]
|
54
56
|
case target
|
55
57
|
when Proc
|
@@ -66,6 +68,7 @@ module Cucumber
|
|
66
68
|
|
67
69
|
def initialize(id, registry, expression, proc)
|
68
70
|
raise 'No regexp' if expression.is_a?(Regexp)
|
71
|
+
|
69
72
|
@id = id
|
70
73
|
@registry = registry
|
71
74
|
@expression = expression
|
@@ -77,7 +80,7 @@ module Cucumber
|
|
77
80
|
Cucumber::Messages::Envelope.new(
|
78
81
|
step_definition: Cucumber::Messages::StepDefinition.new(
|
79
82
|
id: id,
|
80
|
-
pattern: Cucumber::Messages::
|
83
|
+
pattern: Cucumber::Messages::StepDefinitionPattern.new(
|
81
84
|
source: expression.source.to_s,
|
82
85
|
type: expression_type
|
83
86
|
),
|
@@ -92,8 +95,9 @@ module Cucumber
|
|
92
95
|
end
|
93
96
|
|
94
97
|
def expression_type
|
95
|
-
return Cucumber::Messages::
|
96
|
-
|
98
|
+
return Cucumber::Messages::StepDefinitionPatternType::CUCUMBER_EXPRESSION if expression.is_a?(CucumberExpressions::CucumberExpression)
|
99
|
+
|
100
|
+
Cucumber::Messages::StepDefinitionPatternType::REGULAR_EXPRESSION
|
97
101
|
end
|
98
102
|
|
99
103
|
# @api private
|
@@ -123,9 +127,7 @@ module Cucumber
|
|
123
127
|
|
124
128
|
# @api private
|
125
129
|
def arguments_from(step_name)
|
126
|
-
|
127
|
-
# @registry.invoked_step_definition(regexp_source, location) if args
|
128
|
-
args
|
130
|
+
@expression.match(step_name)
|
129
131
|
end
|
130
132
|
|
131
133
|
# @api private
|
data/lib/cucumber/hooks.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Cucumber
|
2
2
|
module MultilineArgument
|
3
3
|
class DataTable
|
4
|
-
class DiffMatrices
|
4
|
+
class DiffMatrices # :nodoc:
|
5
5
|
attr_accessor :cell_matrix, :other_table_cell_matrix, :options
|
6
6
|
|
7
7
|
def initialize(cell_matrix, other_table_cell_matrix, options)
|
@@ -113,6 +113,7 @@ module Cucumber
|
|
113
113
|
row_index = row_indices.index(i)
|
114
114
|
row = cell_matrix[row_index] if row_index
|
115
115
|
next unless row
|
116
|
+
|
116
117
|
(original_width..padded_width).each do |col_index|
|
117
118
|
surplus_cell = other_row[col_index]
|
118
119
|
row[col_index].value = surplus_cell.value if row[col_index]
|