cucumber 7.1.0 → 9.2.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.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +17 -27
  3. data/VERSION +1 -0
  4. data/lib/cucumber/cli/configuration.rb +4 -1
  5. data/lib/cucumber/cli/main.rb +5 -4
  6. data/lib/cucumber/cli/options.rb +73 -67
  7. data/lib/cucumber/cli/profile_loader.rb +6 -10
  8. data/lib/cucumber/cli/rerun_file.rb +1 -1
  9. data/lib/cucumber/configuration.rb +12 -6
  10. data/lib/cucumber/constantize.rb +1 -1
  11. data/lib/cucumber/deprecate.rb +6 -46
  12. data/lib/cucumber/errors.rb +3 -2
  13. data/lib/cucumber/events/envelope.rb +2 -0
  14. data/lib/cucumber/events/gherkin_source_parsed.rb +2 -0
  15. data/lib/cucumber/events/gherkin_source_read.rb +2 -0
  16. data/lib/cucumber/events/hook_test_step_created.rb +1 -2
  17. data/lib/cucumber/events/step_activated.rb +0 -6
  18. data/lib/cucumber/events/step_definition_registered.rb +0 -5
  19. data/lib/cucumber/events/test_case_created.rb +1 -2
  20. data/lib/cucumber/events/test_case_finished.rb +2 -0
  21. data/lib/cucumber/events/test_case_started.rb +2 -0
  22. data/lib/cucumber/events/test_run_finished.rb +2 -1
  23. data/lib/cucumber/events/test_step_created.rb +1 -2
  24. data/lib/cucumber/events/test_step_finished.rb +2 -0
  25. data/lib/cucumber/events/test_step_started.rb +2 -0
  26. data/lib/cucumber/events/undefined_parameter_type.rb +3 -2
  27. data/lib/cucumber/events.rb +1 -1
  28. data/lib/cucumber/file_specs.rb +2 -1
  29. data/lib/cucumber/filters/activate_steps.rb +1 -0
  30. data/lib/cucumber/filters/retry.rb +20 -1
  31. data/lib/cucumber/filters/tag_limits/verifier.rb +1 -3
  32. data/lib/cucumber/filters/tag_limits.rb +1 -3
  33. data/lib/cucumber/formatter/ansicolor.rb +70 -78
  34. data/lib/cucumber/formatter/ast_lookup.rb +16 -8
  35. data/lib/cucumber/formatter/backtrace_filter.rb +2 -1
  36. data/lib/cucumber/formatter/console.rb +26 -16
  37. data/lib/cucumber/formatter/console_counts.rb +3 -1
  38. data/lib/cucumber/formatter/console_issues.rb +10 -3
  39. data/lib/cucumber/formatter/curl_option_parser.rb +49 -0
  40. data/lib/cucumber/formatter/duration_extractor.rb +1 -0
  41. data/lib/cucumber/formatter/errors.rb +3 -0
  42. data/lib/cucumber/formatter/fail_fast.rb +1 -1
  43. data/lib/cucumber/formatter/fanout.rb +1 -1
  44. data/lib/cucumber/formatter/html.rb +2 -0
  45. data/lib/cucumber/formatter/http_io.rb +10 -137
  46. data/lib/cucumber/formatter/ignore_missing_messages.rb +1 -1
  47. data/lib/cucumber/formatter/io.rb +5 -3
  48. data/lib/cucumber/formatter/io_http_buffer.rb +88 -0
  49. data/lib/cucumber/formatter/json.rb +10 -12
  50. data/lib/cucumber/formatter/junit.rb +10 -7
  51. data/lib/cucumber/formatter/message_builder.rb +24 -8
  52. data/lib/cucumber/formatter/pretty.rb +24 -10
  53. data/lib/cucumber/formatter/progress.rb +1 -0
  54. data/lib/cucumber/formatter/publish_banner_printer.rb +0 -2
  55. data/lib/cucumber/formatter/query/hook_by_test_step.rb +3 -0
  56. data/lib/cucumber/formatter/query/pickle_by_test.rb +2 -0
  57. data/lib/cucumber/formatter/query/pickle_step_by_test_step.rb +2 -0
  58. data/lib/cucumber/formatter/query/step_definitions_by_test_step.rb +2 -0
  59. data/lib/cucumber/formatter/query/test_case_started_by_test_case.rb +4 -0
  60. data/lib/cucumber/formatter/rerun.rb +5 -3
  61. data/lib/cucumber/formatter/summary.rb +1 -0
  62. data/lib/cucumber/formatter/unicode.rb +7 -7
  63. data/lib/cucumber/formatter/url_reporter.rb +3 -1
  64. data/lib/cucumber/formatter/usage.rb +3 -3
  65. data/lib/cucumber/gherkin/data_table_parser.rb +1 -0
  66. data/lib/cucumber/gherkin/formatter/ansi_escapes.rb +25 -27
  67. data/lib/cucumber/glue/dsl.rb +20 -25
  68. data/lib/cucumber/glue/hook.rb +6 -3
  69. data/lib/cucumber/glue/invoke_in_world.rb +5 -5
  70. data/lib/cucumber/glue/proto_world.rb +30 -34
  71. data/lib/cucumber/glue/registry_and_more.rb +15 -25
  72. data/lib/cucumber/glue/snippet.rb +4 -2
  73. data/lib/cucumber/glue/step_definition.rb +6 -3
  74. data/lib/cucumber/glue/world_factory.rb +2 -0
  75. data/lib/cucumber/hooks.rb +1 -0
  76. data/lib/cucumber/multiline_argument/data_table/diff_matrices.rb +4 -1
  77. data/lib/cucumber/multiline_argument/data_table.rb +68 -80
  78. data/lib/cucumber/platform.rb +11 -16
  79. data/lib/cucumber/rake/task.rb +22 -15
  80. data/lib/cucumber/rspec/disable_option_parser.rb +6 -3
  81. data/lib/cucumber/running_test_case.rb +2 -1
  82. data/lib/cucumber/runtime/for_programming_languages.rb +1 -2
  83. data/lib/cucumber/runtime/meta_message_builder.rb +108 -0
  84. data/lib/cucumber/runtime/support_code.rb +3 -0
  85. data/lib/cucumber/runtime/user_interface.rb +7 -6
  86. data/lib/cucumber/runtime.rb +22 -38
  87. data/lib/cucumber/step_match.rb +6 -4
  88. data/lib/cucumber/step_match_search.rb +3 -2
  89. data/lib/cucumber/term/ansicolor.rb +74 -50
  90. data/lib/cucumber/term/banner.rb +3 -0
  91. data/lib/cucumber.rb +2 -1
  92. data/lib/simplecov_setup.rb +1 -1
  93. metadata +95 -244
  94. data/CHANGELOG.md +0 -3131
  95. data/CONTRIBUTING.md +0 -250
  96. data/lib/autotest/cucumber.rb +0 -8
  97. data/lib/autotest/cucumber_mixin.rb +0 -130
  98. data/lib/autotest/cucumber_rails.rb +0 -8
  99. data/lib/autotest/cucumber_rails_rspec.rb +0 -8
  100. data/lib/autotest/cucumber_rails_rspec2.rb +0 -8
  101. data/lib/autotest/cucumber_rspec.rb +0 -8
  102. data/lib/autotest/cucumber_rspec2.rb +0 -8
  103. data/lib/autotest/discover.rb +0 -13
  104. data/lib/cucumber/version +0 -1
@@ -19,8 +19,8 @@ module Cucumber
19
19
  @rb_language.build_rb_world_factory(world_modules, namespaced_world_modules, proc)
20
20
  end
21
21
 
22
- def register_rb_hook(phase, tag_names, proc)
23
- @rb_language.register_rb_hook(phase, tag_names, proc)
22
+ def register_rb_hook(phase, tag_names, proc, name: nil)
23
+ @rb_language.register_rb_hook(phase, tag_names, proc, name: name)
24
24
  end
25
25
 
26
26
  def define_parameter_type(parameter_type)
@@ -62,14 +62,14 @@ module Cucumber
62
62
 
63
63
  # Registers a proc that will run before each Scenario. You can register as many
64
64
  # as you want (typically from ruby scripts under <tt>support/hooks.rb</tt>).
65
- def Before(*tag_expressions, &proc)
66
- Dsl.register_rb_hook('before', tag_expressions, proc)
65
+ def Before(*tag_expressions, name: nil, &proc)
66
+ Dsl.register_rb_hook('before', tag_expressions, proc, name: name)
67
67
  end
68
68
 
69
69
  # Registers a proc that will run after each Scenario. You can register as many
70
70
  # as you want (typically from ruby scripts under <tt>support/hooks.rb</tt>).
71
- def After(*tag_expressions, &proc)
72
- Dsl.register_rb_hook('after', tag_expressions, proc)
71
+ def After(*tag_expressions, name: nil, &proc)
72
+ Dsl.register_rb_hook('after', tag_expressions, proc, name: name)
73
73
  end
74
74
 
75
75
  # Registers a proc that will be wrapped around each scenario. The proc
@@ -77,14 +77,14 @@ module Cucumber
77
77
  # argument (but passed as a regular argument, since blocks cannot accept
78
78
  # blocks in 1.8), on which it should call the .call method. You can register
79
79
  # as many as you want (typically from ruby scripts under <tt>support/hooks.rb</tt>).
80
- def Around(*tag_expressions, &proc)
81
- Dsl.register_rb_hook('around', tag_expressions, proc)
80
+ def Around(*tag_expressions, name: nil, &proc)
81
+ Dsl.register_rb_hook('around', tag_expressions, proc, name: name)
82
82
  end
83
83
 
84
84
  # Registers a proc that will run after each Step. You can register as
85
85
  # as you want (typically from ruby scripts under <tt>support/hooks.rb</tt>).
86
- def AfterStep(*tag_expressions, &proc)
87
- Dsl.register_rb_hook('after_step', tag_expressions, proc)
86
+ def AfterStep(*tag_expressions, name: nil, &proc)
87
+ Dsl.register_rb_hook('after_step', tag_expressions, proc, name: name)
88
88
  end
89
89
 
90
90
  def ParameterType(options)
@@ -107,29 +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. You can register as
111
- # as you want (typically from ruby scripts under <tt>support/hooks.rb</tt>).
112
- #
113
- # DEPRECATED: please use InstallPlugin or BeforeAll instead
114
- def AfterConfiguration(&proc)
115
- Dsl.register_rb_hook('after_configuration', [], proc)
116
- end
117
-
118
110
  # Registers a proc that will run after Cucumber is configured in order to install an external plugin.
119
- def InstallPlugin(&proc)
120
- Dsl.register_rb_hook('install_plugin', [], proc)
111
+ def InstallPlugin(name: nil, &proc)
112
+ Dsl.register_rb_hook('install_plugin', [], proc, name: name)
121
113
  end
122
114
 
123
115
  # Registers a proc that will run before the execution of the scenarios.
124
116
  # Use it for your final set-ups
125
- def BeforeAll(&proc)
126
- Dsl.register_rb_hook('before_all', [], proc)
117
+ def BeforeAll(name: nil, &proc)
118
+ Dsl.register_rb_hook('before_all', [], proc, name: name)
127
119
  end
128
120
 
129
121
  # Registers a proc that will run after the execution of the scenarios.
130
122
  # Use it for your final clean-ups
131
- def AfterAll(&proc)
132
- Dsl.register_rb_hook('after_all', [], proc)
123
+ def AfterAll(name: nil, &proc)
124
+ Dsl.register_rb_hook('after_all', [], proc, name: name)
133
125
  end
134
126
 
135
127
  # Registers a new Ruby StepDefinition. This method is aliased
@@ -155,5 +147,8 @@ module Cucumber
155
147
  end
156
148
  end
157
149
 
158
- # TODO: can we avoid adding methods to the global namespace (Kernel)
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
159
153
  extend(Cucumber::Glue::Dsl)
154
+ # rubocop:enable Style/MixinUsage
@@ -6,11 +6,12 @@ module Cucumber
6
6
  module Glue
7
7
  # TODO: Kill pointless wrapper for Before, After and AfterStep hooks with fire
8
8
  class Hook
9
- attr_reader :id, :tag_expressions, :location
9
+ attr_reader :id, :tag_expressions, :location, :name
10
10
 
11
- def initialize(id, registry, tag_expressions, proc)
11
+ def initialize(id, registry, tag_expressions, proc, name: nil)
12
12
  @id = id
13
13
  @registry = registry
14
+ @name = name
14
15
  @tag_expressions = sanitize_tag_expressions(tag_expressions)
15
16
  @proc = proc
16
17
  @location = Cucumber::Core::Test::Location.from_source_location(*@proc.source_location)
@@ -32,7 +33,8 @@ module Cucumber
32
33
  Cucumber::Messages::Envelope.new(
33
34
  hook: Cucumber::Messages::Hook.new(
34
35
  id: id,
35
- tag_expression: tag_expressions.join(' '),
36
+ name: name,
37
+ tag_expression: tag_expressions.empty? ? nil : tag_expressions.join(' '),
36
38
  source_reference: Cucumber::Messages::SourceReference.new(
37
39
  uri: location.file,
38
40
  location: Cucumber::Messages::Location.new(
@@ -58,6 +60,7 @@ module Cucumber
58
60
  end
59
61
 
60
62
  next unless tag_expression.include?(',')
63
+
61
64
  warn("Found tagged hook with '#{tag_expression}'." \
62
65
  "'@tag1,@tag2' is no longer supported, use '@tag or @tag2' instead.")
63
66
  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 ? (ari.abs - 1).to_s + '+' : ari
31
+ ari = ari.negative? ? "#{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,15 +41,14 @@ 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 < 0
44
- return true if args.length >= (block.arity.abs - 1)
45
- end
44
+ return true if block.arity.negative? && args.length >= (block.arity.abs - 1)
45
+
46
46
  false
47
47
  end
48
48
 
49
49
  def self.cucumber_run_with_backtrace_filtering(pseudo_method)
50
50
  yield
51
- rescue Exception => e # rubocop:disable Lint/RescueException
51
+ rescue Exception => e
52
52
  instance_exec_invocation_line = "#{__FILE__}:#{__LINE__ - 2}:in `cucumber_run_with_backtrace_filtering'"
53
53
  replace_instance_exec_invocation_line!((e.backtrace || []), instance_exec_invocation_line, pseudo_method)
54
54
  raise e
@@ -3,11 +3,11 @@
3
3
  require 'cucumber/gherkin/formatter/ansi_escapes'
4
4
  require 'cucumber/core/test/data_table'
5
5
  require 'cucumber/deprecate'
6
- require 'mime/types'
6
+ require 'mini_mime'
7
7
 
8
8
  module Cucumber
9
9
  module Glue
10
- # Defines the basic API methods availlable in all Cucumber step definitions.
10
+ # Defines the basic API methods available in all Cucumber step definitions.
11
11
  #
12
12
  # You can, and probably should, extend this API with your own methods that
13
13
  # make sense in your domain. For more on that, see {Cucumber::Glue::Dsl#World}
@@ -26,7 +26,7 @@ module Cucumber
26
26
  # @example Passing a multiline string
27
27
  # step "the email should contain:", "Dear sir,\nYou've won a prize!\n"
28
28
  # @param [String] name The name of the step
29
- # @param [String,Cucumber::Test::DocString,Cucumber::Ast::Table] multiline_argument
29
+ # @param [String, Cucumber::Test::DocString, Cucumber::Ast::Table] raw_multiline_arg
30
30
  def step(name, raw_multiline_arg = nil)
31
31
  super
32
32
  end
@@ -84,17 +84,19 @@ module Cucumber
84
84
 
85
85
  # Attach a file to the output
86
86
  # @param file [string|io] the file to attach.
87
- # It can be a string containing the file content itself,
88
- # the file path, or an IO ready to be read.
89
- # @param media_type [string] the media type. If file is a valid path,
90
- # media_type can be ommitted, it will then be inferred from the file name.
91
- def attach(file, media_type = nil)
87
+ # It can be a string containing the file content itself, the file path, or an IO ready to be read.
88
+ # @param media_type [string] the media type.
89
+ # If file is a valid path, media_type can be omitted, it will then be inferred from the file name.
90
+ # @param filename [string] the name of the file you wish to specify.
91
+ # This is only needed in situations where you want to rename a PDF download e.t.c. - In most situations
92
+ # you should not need to pass a filename
93
+ def attach(file, media_type = nil, filename = nil)
92
94
  return super unless File.file?(file)
93
95
 
94
96
  content = File.read(file, mode: 'rb')
95
- media_type = MIME::Types.type_for(file).first if media_type.nil?
97
+ media_type = MiniMime.lookup_by_filename(file)&.content_type if media_type.nil?
96
98
 
97
- super(content, media_type.to_s)
99
+ super(content, media_type.to_s, filename)
98
100
  rescue StandardError
99
101
  super
100
102
  end
@@ -103,12 +105,9 @@ module Cucumber
103
105
  def pending(message = 'TODO')
104
106
  raise Pending, message unless block_given?
105
107
 
106
- begin
107
- yield
108
- rescue Exception # rubocop:disable Lint/RescueException
109
- raise Pending, message
110
- end
111
- raise Pending, "Expected pending '#{message}' to fail. No Error was raised. No longer pending?"
108
+ yield
109
+ rescue Exception
110
+ raise Pending, message
112
111
  end
113
112
 
114
113
  # Skips this step and the remaining steps in the scenario
@@ -126,9 +125,9 @@ module Cucumber
126
125
  inspect
127
126
  end
128
127
 
129
- # Dynamially generate the API module, closuring the dependencies
130
- def self.for(runtime, language) # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
131
- Module.new do # rubocop:disable Metrics/BlockLength
128
+ # Dynamically generate the API module, closuring the dependencies
129
+ def self.for(runtime, language)
130
+ Module.new do
132
131
  def self.extended(object)
133
132
  # wrap the dynamically generated module so that we can document the methods
134
133
  # for yardoc, which doesn't like define_method.
@@ -138,8 +137,8 @@ module Cucumber
138
137
  # TODO: pass these in when building the module, instead of mutating them later
139
138
  # Extend the World with user-defined modules
140
139
  def add_modules!(world_modules, namespaced_world_modules)
141
- add_world_modules!(world_modules)
142
- add_namespaced_modules!(namespaced_world_modules)
140
+ add_world_modules!(world_modules) if world_modules.any?
141
+ add_namespaced_modules!(namespaced_world_modules) if namespaced_world_modules.any?
143
142
  end
144
143
 
145
144
  define_method(:step) do |name, raw_multiline_arg = nil|
@@ -156,8 +155,8 @@ module Cucumber
156
155
  runtime.ask(question, timeout_seconds)
157
156
  end
158
157
 
159
- define_method(:attach) do |file, media_type|
160
- runtime.attach(file, media_type)
158
+ define_method(:attach) do |file, media_type, filename|
159
+ runtime.attach(file, media_type, filename)
161
160
  end
162
161
 
163
162
  # Prints the list of modules that are included in the World
@@ -172,27 +171,24 @@ module Cucumber
172
171
 
173
172
  private
174
173
 
175
- # @private
176
174
  def add_world_modules!(modules)
177
175
  modules.each do |world_module|
178
176
  extend(world_module)
179
177
  end
180
178
  end
181
179
 
182
- # @private
183
180
  def add_namespaced_modules!(modules)
184
181
  @__namespaced_modules = modules
185
182
  modules.each do |namespace, world_modules|
186
183
  world_modules.each do |world_module|
187
184
  variable_name = "@__#{namespace}_world"
185
+ inner_world = instance_variable_get(variable_name) || Object.new
186
+
187
+ instance_variable_set(
188
+ variable_name,
189
+ inner_world.extend(world_module)
190
+ )
188
191
 
189
- inner_world = if self.class.respond_to?(namespace)
190
- instance_variable_get(variable_name)
191
- else
192
- Object.new
193
- end
194
- instance_variable_set(variable_name,
195
- inner_world.extend(world_module))
196
192
  self.class.send(:define_method, namespace) do
197
193
  instance_variable_get(variable_name)
198
194
  end
@@ -200,14 +196,14 @@ module Cucumber
200
196
  end
201
197
  end
202
198
 
203
- # @private
204
199
  def stringify_namespaced_modules
200
+ return '' if @__namespaced_modules.nil?
201
+
205
202
  @__namespaced_modules.map { |k, v| "#{v.join(',')} (as #{k})" }.join('+')
206
203
  end
207
204
  end
208
205
  end
209
206
 
210
- # @private
211
207
  AnsiEscapes = Cucumber::Gherkin::Formatter::AnsiEscapes
212
208
  end
213
209
  end
@@ -29,7 +29,8 @@ module Cucumber
29
29
  # Raised if there are 2 or more World blocks.
30
30
  class MultipleWorld < StandardError
31
31
  def initialize(first_proc, second_proc)
32
- message = String.new # rubocop:disable Style/EmptyLiteral
32
+ # TODO: [LH] - Just use a heredoc here to fix this up
33
+ message = String.new
33
34
  message << "You can only pass a proc to #World once, but it's happening\n"
34
35
  message << "in 2 places:\n\n"
35
36
  message << Glue.backtrace_line(first_proc, 'World') << "\n"
@@ -72,8 +73,8 @@ module Cucumber
72
73
  end
73
74
  end
74
75
 
75
- def register_rb_hook(phase, tag_expressions, proc)
76
- hook = add_hook(phase, Hook.new(@configuration.id_generator.new_id, self, tag_expressions, proc))
76
+ def register_rb_hook(phase, tag_expressions, proc, name: nil)
77
+ hook = add_hook(phase, Hook.new(@configuration.id_generator.new_id, self, tag_expressions, proc, name: name))
77
78
  @configuration.notify :envelope, hook.to_envelope
78
79
  hook
79
80
  end
@@ -92,7 +93,7 @@ module Cucumber
92
93
  step_definition
93
94
  rescue Cucumber::CucumberExpressions::UndefinedParameterTypeError => e
94
95
  # TODO: add a way to extract the parameter type directly from the error.
95
- type_name = e.message.match(/^Undefined parameter type ['|\{](.*)['|\}].?$/)[1]
96
+ type_name = e.message.match(/^Undefined parameter type ['|{](.*)['|}].?$/)[1]
96
97
 
97
98
  @configuration.notify :undefined_parameter_type, type_name, string_or_regexp
98
99
  end
@@ -100,6 +101,7 @@ module Cucumber
100
101
  def build_rb_world_factory(world_modules, namespaced_world_modules, proc)
101
102
  if proc
102
103
  raise MultipleWorld.new(@world_proc, proc) if @world_proc
104
+
103
105
  @world_proc = proc
104
106
  end
105
107
  @world_modules ||= []
@@ -135,14 +137,6 @@ module Cucumber
135
137
  @current_world = nil
136
138
  end
137
139
 
138
- def after_configuration(configuration)
139
- deprecate_after_configuration_hook if hooks[:after_configuration].any?
140
-
141
- hooks[:after_configuration].each do |hook|
142
- hook.invoke('AfterConfiguration', configuration)
143
- end
144
- end
145
-
146
140
  def install_plugin(configuration, registry)
147
141
  hooks[:install_plugin].each do |hook|
148
142
  hook.invoke('InstallPlugin', [configuration, registry])
@@ -170,7 +164,7 @@ module Cucumber
170
164
  @hooks = nil
171
165
  end
172
166
 
173
- def hooks_for(phase, scenario) #:nodoc:
167
+ def hooks_for(phase, scenario) # :nodoc:
174
168
  hooks[phase.to_sym].select { |hook| scenario.accept_hook?(hook) }
175
169
  end
176
170
 
@@ -189,6 +183,7 @@ module Cucumber
189
183
  def create_expression(string_or_regexp)
190
184
  return CucumberExpressions::CucumberExpression.new(string_or_regexp, @parameter_type_registry) if string_or_regexp.is_a?(String)
191
185
  return CucumberExpressions::RegularExpression.new(string_or_regexp, @parameter_type_registry) if string_or_regexp.is_a?(Regexp)
186
+
192
187
  raise ArgumentError, 'Expression must be a String or Regexp'
193
188
  end
194
189
 
@@ -203,16 +198,19 @@ module Cucumber
203
198
  private
204
199
 
205
200
  def parameter_type_envelope(parameter_type)
206
- # TODO: should me moved to Cucumber::Expression::ParameterType#to_envelope ?
201
+ # TODO: should this be moved to Cucumber::Expression::ParameterType#to_envelope ??
207
202
  # Note: that would mean that cucumber-expression would depend on cucumber-messages
208
-
209
203
  Cucumber::Messages::Envelope.new(
210
204
  parameter_type: Cucumber::Messages::ParameterType.new(
211
205
  id: @configuration.id_generator.new_id,
212
206
  name: parameter_type.name,
213
207
  regular_expressions: parameter_type.regexps.map(&:to_s),
214
- prefer_for_regular_expression_match: parameter_type.prefer_for_regexp_match?,
215
- use_for_snippets: parameter_type.use_for_snippets?
208
+ prefer_for_regular_expression_match: parameter_type.prefer_for_regexp_match,
209
+ use_for_snippets: parameter_type.use_for_snippets,
210
+ source_reference: Cucumber::Messages::SourceReference.new(
211
+ uri: parameter_type.transformer.source_location[0],
212
+ location: Cucumber::Messages::Location.new(line: parameter_type.transformer.source_location[1])
213
+ )
216
214
  )
217
215
  )
218
216
  end
@@ -228,14 +226,6 @@ module Cucumber
228
226
  def hooks
229
227
  @hooks ||= Hash.new { |h, k| h[k] = [] }
230
228
  end
231
-
232
- def deprecate_after_configuration_hook
233
- Cucumber.deprecate(
234
- 'See https://github.com/cucumber/cucumber-ruby/blob/main/UPGRADING.md#upgrading-to-710 for more info',
235
- ' AfterConfiguration hook',
236
- '8.0.0'
237
- )
238
- end
239
229
  end
240
230
 
241
231
  def self.backtrace_line(proc, name)
@@ -61,7 +61,8 @@ module Cucumber
61
61
  end
62
62
 
63
63
  def do_block
64
- do_block = String.new # rubocop:disable Style/EmptyLiteral
64
+ # TODO: [LH] - Just use a heredoc here to fix this up
65
+ do_block = String.new
65
66
  do_block << "do#{parameters}\n"
66
67
  multiline_argument.append_comment_to(do_block)
67
68
  do_block << " pending # Write code here that turns the phrase above into concrete actions\n"
@@ -95,7 +96,8 @@ module Cucumber
95
96
  "#{prefix}#{code_keyword}('#{expr.source}') do#{parameters(expr)}"
96
97
  end.join("\n")
97
98
 
98
- body = String.new # rubocop:disable Style/EmptyLiteral
99
+ # TODO: [LH] - Just use a heredoc here to fix this up
100
+ body = String.new
99
101
  multiline_argument.append_comment_to(body)
100
102
  body << " pending # Write code here that turns the phrase above into concrete actions\n"
101
103
  body << 'end'
@@ -25,6 +25,7 @@ module Cucumber
25
25
  class << self
26
26
  def new(id, registry, string_or_regexp, proc_or_sym, options)
27
27
  raise MissingProc if proc_or_sym.nil?
28
+
28
29
  super id, registry, registry.create_expression(string_or_regexp), create_proc(proc_or_sym, options)
29
30
  end
30
31
 
@@ -33,6 +34,7 @@ module Cucumber
33
34
  def create_proc(proc_or_sym, options)
34
35
  return proc_or_sym if proc_or_sym.is_a?(Proc)
35
36
  raise ArgumentError unless proc_or_sym.is_a?(Symbol)
37
+
36
38
  message = proc_or_sym
37
39
  target_proc = parse_target_proc_from(options)
38
40
  patch_location_onto lambda { |*args|
@@ -49,6 +51,7 @@ module Cucumber
49
51
 
50
52
  def parse_target_proc_from(options)
51
53
  return -> { self } unless options.key?(:on)
54
+
52
55
  target = options[:on]
53
56
  case target
54
57
  when Proc
@@ -65,6 +68,7 @@ module Cucumber
65
68
 
66
69
  def initialize(id, registry, expression, proc)
67
70
  raise 'No regexp' if expression.is_a?(Regexp)
71
+
68
72
  @id = id
69
73
  @registry = registry
70
74
  @expression = expression
@@ -92,6 +96,7 @@ module Cucumber
92
96
 
93
97
  def expression_type
94
98
  return Cucumber::Messages::StepDefinitionPatternType::CUCUMBER_EXPRESSION if expression.is_a?(CucumberExpressions::CucumberExpression)
99
+
95
100
  Cucumber::Messages::StepDefinitionPatternType::REGULAR_EXPRESSION
96
101
  end
97
102
 
@@ -122,9 +127,7 @@ module Cucumber
122
127
 
123
128
  # @api private
124
129
  def arguments_from(step_name)
125
- args = @expression.match(step_name)
126
- # @registry.invoked_step_definition(regexp_source, location) if args
127
- args
130
+ @expression.match(step_name)
128
131
  end
129
132
 
130
133
  # @api private
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Cucumber
2
4
  module Glue
3
5
  class WorldFactory
@@ -19,6 +19,7 @@ module Cucumber
19
19
 
20
20
  def after_step_hook(id, test_step, location, &block)
21
21
  raise ArgumentError if test_step.hook?
22
+
22
23
  build_hook_step(id, location, block, AfterStepHook, Core::Test::Action)
23
24
  end
24
25
 
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Cucumber
2
4
  module MultilineArgument
3
5
  class DataTable
4
- class DiffMatrices #:nodoc:
6
+ class DiffMatrices # :nodoc:
5
7
  attr_accessor :cell_matrix, :other_table_cell_matrix, :options
6
8
 
7
9
  def initialize(cell_matrix, other_table_cell_matrix, options)
@@ -113,6 +115,7 @@ module Cucumber
113
115
  row_index = row_indices.index(i)
114
116
  row = cell_matrix[row_index] if row_index
115
117
  next unless row
118
+
116
119
  (original_width..padded_width).each do |col_index|
117
120
  surplus_cell = other_row[col_index]
118
121
  row[col_index].value = surplus_cell.value if row[col_index]