cucumber 3.1.2 → 4.0.0.rc.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +68 -13
  3. data/CONTRIBUTING.md +1 -0
  4. data/bin/cucumber +1 -1
  5. data/lib/autotest/cucumber_mixin.rb +42 -39
  6. data/lib/cucumber/cli/configuration.rb +4 -4
  7. data/lib/cucumber/cli/main.rb +11 -12
  8. data/lib/cucumber/cli/options.rb +53 -62
  9. data/lib/cucumber/cli/profile_loader.rb +32 -20
  10. data/lib/cucumber/configuration.rb +20 -21
  11. data/lib/cucumber/constantize.rb +2 -5
  12. data/lib/cucumber/deprecate.rb +5 -5
  13. data/lib/cucumber/errors.rb +4 -6
  14. data/lib/cucumber/events.rb +1 -0
  15. data/lib/cucumber/events/gherkin_source_parsed.rb +11 -0
  16. data/lib/cucumber/events/step_activated.rb +2 -1
  17. data/lib/cucumber/file_specs.rb +6 -6
  18. data/lib/cucumber/filters/activate_steps.rb +5 -3
  19. data/lib/cucumber/filters/prepare_world.rb +5 -9
  20. data/lib/cucumber/filters/quit.rb +1 -3
  21. data/lib/cucumber/filters/tag_limits/verifier.rb +2 -4
  22. data/lib/cucumber/formatter/ansicolor.rb +40 -45
  23. data/lib/cucumber/formatter/ast_lookup.rb +160 -0
  24. data/lib/cucumber/formatter/backtrace_filter.rb +5 -7
  25. data/lib/cucumber/formatter/console.rb +28 -59
  26. data/lib/cucumber/formatter/console_counts.rb +4 -9
  27. data/lib/cucumber/formatter/console_issues.rb +6 -3
  28. data/lib/cucumber/formatter/duration_extractor.rb +1 -1
  29. data/lib/cucumber/formatter/fanout.rb +2 -0
  30. data/lib/cucumber/formatter/ignore_missing_messages.rb +1 -1
  31. data/lib/cucumber/formatter/interceptor.rb +5 -7
  32. data/lib/cucumber/formatter/io.rb +3 -3
  33. data/lib/cucumber/formatter/json.rb +92 -110
  34. data/lib/cucumber/formatter/junit.rb +55 -57
  35. data/lib/cucumber/formatter/pretty.rb +346 -152
  36. data/lib/cucumber/formatter/progress.rb +28 -32
  37. data/lib/cucumber/formatter/rerun.rb +22 -4
  38. data/lib/cucumber/formatter/stepdefs.rb +1 -2
  39. data/lib/cucumber/formatter/steps.rb +2 -3
  40. data/lib/cucumber/formatter/summary.rb +16 -8
  41. data/lib/cucumber/formatter/unicode.rb +15 -17
  42. data/lib/cucumber/formatter/usage.rb +9 -8
  43. data/lib/cucumber/gherkin/data_table_parser.rb +8 -6
  44. data/lib/cucumber/gherkin/formatter/ansi_escapes.rb +13 -17
  45. data/lib/cucumber/gherkin/formatter/escaping.rb +2 -2
  46. data/lib/cucumber/gherkin/steps_parser.rb +7 -8
  47. data/lib/cucumber/glue/dsl.rb +1 -1
  48. data/lib/cucumber/glue/hook.rb +16 -9
  49. data/lib/cucumber/glue/invoke_in_world.rb +13 -18
  50. data/lib/cucumber/glue/proto_world.rb +14 -16
  51. data/lib/cucumber/glue/registry_and_more.rb +7 -9
  52. data/lib/cucumber/glue/snippet.rb +21 -20
  53. data/lib/cucumber/glue/step_definition.rb +14 -15
  54. data/lib/cucumber/glue/world_factory.rb +1 -1
  55. data/lib/cucumber/hooks.rb +11 -11
  56. data/lib/cucumber/multiline_argument.rb +4 -6
  57. data/lib/cucumber/multiline_argument/data_table.rb +88 -59
  58. data/lib/cucumber/multiline_argument/data_table/diff_matrices.rb +1 -1
  59. data/lib/cucumber/multiline_argument/doc_string.rb +1 -1
  60. data/lib/cucumber/platform.rb +3 -3
  61. data/lib/cucumber/rake/task.rb +13 -16
  62. data/lib/cucumber/rspec/disable_option_parser.rb +9 -8
  63. data/lib/cucumber/running_test_case.rb +2 -53
  64. data/lib/cucumber/runtime.rb +27 -57
  65. data/lib/cucumber/runtime/after_hooks.rb +3 -3
  66. data/lib/cucumber/runtime/before_hooks.rb +3 -3
  67. data/lib/cucumber/runtime/for_programming_languages.rb +3 -2
  68. data/lib/cucumber/runtime/step_hooks.rb +1 -1
  69. data/lib/cucumber/runtime/support_code.rb +10 -12
  70. data/lib/cucumber/runtime/user_interface.rb +4 -6
  71. data/lib/cucumber/step_definition_light.rb +4 -3
  72. data/lib/cucumber/step_match.rb +12 -11
  73. data/lib/cucumber/step_match_search.rb +2 -1
  74. data/lib/cucumber/term/ansicolor.rb +9 -9
  75. data/lib/cucumber/version +1 -1
  76. metadata +36 -29
  77. data/lib/cucumber/events/gherkin_source_parsed.rb~ +0 -14
  78. data/lib/cucumber/formatter/ast_lookup.rb~ +0 -9
  79. data/lib/cucumber/formatter/cucumber.css +0 -286
  80. data/lib/cucumber/formatter/cucumber.sass +0 -247
  81. data/lib/cucumber/formatter/hook_query_visitor.rb +0 -42
  82. data/lib/cucumber/formatter/html.rb +0 -611
  83. data/lib/cucumber/formatter/html_builder.rb +0 -121
  84. data/lib/cucumber/formatter/inline-js.js +0 -30
  85. data/lib/cucumber/formatter/jquery-min.js +0 -154
  86. data/lib/cucumber/formatter/json_pretty.rb +0 -11
  87. data/lib/cucumber/formatter/legacy_api/adapter.rb +0 -1028
  88. data/lib/cucumber/formatter/legacy_api/ast.rb +0 -394
  89. data/lib/cucumber/formatter/legacy_api/results.rb +0 -50
  90. data/lib/cucumber/formatter/legacy_api/runtime_facade.rb +0 -32
  91. data/lib/cucumber/step_argument.rb +0 -25
@@ -1,8 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'gherkin/token_scanner'
4
- require 'gherkin/token_matcher'
5
- require 'gherkin/parser'
3
+ require 'gherkin/gherkin'
6
4
  require 'gherkin/dialect'
7
5
 
8
6
  module Cucumber
@@ -15,12 +13,13 @@ module Cucumber
15
13
 
16
14
  def parse(text)
17
15
  dialect = ::Gherkin::Dialect.for(@language)
18
- token_matcher = ::Gherkin::TokenMatcher.new(@language)
19
- token_scanner = ::Gherkin::TokenScanner.new(feature_header(dialect) + text)
20
- parser = ::Gherkin::Parser.new
21
- gherkin_document = parser.parse(token_scanner, token_matcher)
16
+ gherkin_document = nil
17
+ messages = ::Gherkin::Gherkin.from_source('dummy', feature_header(dialect) + text, default_dialect: @language, include_source: false, include_pickles: false)
18
+ messages.each do |message|
19
+ gherkin_document = message.gherkinDocument.to_hash unless message.gherkinDocument.nil?
20
+ end
22
21
 
23
- @builder.steps(gherkin_document[:feature][:children][0][:steps])
22
+ @builder.steps(gherkin_document[:feature][:children][0][:scenario][:steps])
24
23
  end
25
24
 
26
25
  def feature_header(dialect)
@@ -137,4 +137,4 @@ module Cucumber
137
137
  end
138
138
 
139
139
  # TODO: can we avoid adding methods to the global namespace (Kernel)
140
- extend(Cucumber::Glue::Dsl)
140
+ extend(Cucumber::Glue::Dsl) # rubocop:disable Style/MixinUsage
@@ -10,10 +10,10 @@ module Cucumber
10
10
 
11
11
  def initialize(registry, tag_expressions, proc)
12
12
  @registry = registry
13
- @tag_expressions = tag_expressions
13
+ @tag_expressions = sanitize_tag_expressions(tag_expressions)
14
14
  @proc = proc
15
- @location = Cucumber::Core::Ast::Location.from_source_location(*@proc.source_location)
16
- warn_for_old_style_tag_expressions(tag_expressions)
15
+ @location = Cucumber::Core::Test::Location.from_source_location(*@proc.source_location)
16
+ fail_for_old_style_tag_expressions(@tag_expressions)
17
17
  end
18
18
 
19
19
  def invoke(pseudo_method, arguments, &block)
@@ -29,14 +29,21 @@ module Cucumber
29
29
 
30
30
  private
31
31
 
32
- def warn_for_old_style_tag_expressions(tag_expressions)
32
+ def sanitize_tag_expressions(tag_expressions)
33
+ # TODO: remove when '~@no-clobber' has been changed to 'not @no-clobber' in aruba
34
+ tag_expressions.map { |tag_expression| tag_expression == '~@no-clobber' ? 'not @no-clobber' : tag_expression }
35
+ end
36
+
37
+ def fail_for_old_style_tag_expressions(tag_expressions)
33
38
  tag_expressions.each do |tag_expression|
34
- if tag_expression.include?('~') && tag_expression != '~@no-clobber' # ~@no-clobber is used in aruba
35
- warn("Deprecated: Found tagged hook with '#{tag_expression}'. Support for '~@tag' will be removed from the next release of Cucumber. Please use 'not @tag' instead.")
36
- end
37
- if tag_expression.include?(',')
38
- warn("Deprecated: Found tagged hook with '#{tag_expression}'. Support for '@tag1,@tag2' will be removed from the next release of Cucumber. Please use '@tag or @tag2' instead.")
39
+ if tag_expression.include?('~')
40
+ raise("Found tagged hook with '#{tag_expression}'." \
41
+ "'~@tag' is no longer supported, use 'not @tag' instead.")
39
42
  end
43
+
44
+ next unless tag_expression.include?(',')
45
+ warn("Found tagged hook with '#{tag_expression}'." \
46
+ "'@tag1,@tag2' is no longer supported, use '@tag or @tag2' instead.")
40
47
  end
41
48
  end
42
49
  end
@@ -11,16 +11,15 @@ module Cucumber
11
11
  return if Cucumber.use_full_backtrace
12
12
 
13
13
  instance_exec_pos = backtrace.index(instance_exec_invocation_line)
14
- if instance_exec_pos
15
- replacement_line = instance_exec_pos + INSTANCE_EXEC_OFFSET
16
- backtrace[replacement_line].gsub!(/`.*'/, "`#{pseudo_method}'") if pseudo_method
14
+ return unless instance_exec_pos
15
+ replacement_line = instance_exec_pos + INSTANCE_EXEC_OFFSET
16
+ backtrace[replacement_line].gsub!(/`.*'/, "`#{pseudo_method}'") if pseudo_method
17
17
 
18
- depth = backtrace.count { |line| line == instance_exec_invocation_line }
19
- end_pos = depth > 1 ? instance_exec_pos : -1
18
+ depth = backtrace.count { |line| line == instance_exec_invocation_line }
19
+ end_pos = depth > 1 ? instance_exec_pos : -1
20
20
 
21
- backtrace[replacement_line + 1..end_pos] = nil
22
- backtrace.compact!
23
- end
21
+ backtrace[replacement_line + 1..end_pos] = nil
22
+ backtrace.compact!
24
23
  end
25
24
 
26
25
  def self.cucumber_instance_exec_in(world, check_arity, pseudo_method, *args, &block)
@@ -31,9 +30,7 @@ module Cucumber
31
30
  ari = ari < 0 ? (ari.abs - 1).to_s + '+' : ari
32
31
  s1 = ari == 1 ? '' : 's'
33
32
  s2 = args.length == 1 ? '' : 's'
34
- raise ArityMismatchError.new(
35
- "Your block takes #{ari} argument#{s1}, but the Regexp matched #{args.length} argument#{s2}."
36
- )
33
+ raise ArityMismatchError, "Your block takes #{ari} argument#{s1}, but the Regexp matched #{args.length} argument#{s2}."
37
34
  end
38
35
  else
39
36
  world.instance_exec(*args, &block)
@@ -50,13 +47,11 @@ module Cucumber
50
47
  end
51
48
 
52
49
  def self.cucumber_run_with_backtrace_filtering(pseudo_method)
53
- begin
54
- yield
55
- rescue Exception => e
56
- instance_exec_invocation_line = "#{__FILE__}:#{__LINE__ - 2}:in `cucumber_run_with_backtrace_filtering'"
57
- replace_instance_exec_invocation_line!((e.backtrace || []), instance_exec_invocation_line, pseudo_method)
58
- raise e
59
- end
50
+ yield
51
+ rescue Exception => e # rubocop:disable Lint/RescueException
52
+ instance_exec_invocation_line = "#{__FILE__}:#{__LINE__ - 2}:in `cucumber_run_with_backtrace_filtering'"
53
+ replace_instance_exec_invocation_line!((e.backtrace || []), instance_exec_invocation_line, pseudo_method)
54
+ raise e
60
55
  end
61
56
 
62
57
  INSTANCE_EXEC_OFFSET = -3
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'cucumber/gherkin/formatter/ansi_escapes'
4
- require 'cucumber/core/ast/data_table'
4
+ require 'cucumber/core/test/data_table'
5
5
 
6
6
  module Cucumber
7
7
  module Glue
@@ -24,7 +24,7 @@ module Cucumber
24
24
  # @example Passing a multiline string
25
25
  # step "the email should contain:", "Dear sir,\nYou've won a prize!\n"
26
26
  # @param [String] name The name of the step
27
- # @param [String,Cucumber::Ast::DocString,Cucumber::Ast::Table] multiline_argument
27
+ # @param [String,Cucumber::Test::DocString,Cucumber::Ast::Table] multiline_argument
28
28
  def step(name, raw_multiline_arg = nil)
29
29
  super
30
30
  end
@@ -68,7 +68,7 @@ module Cucumber
68
68
  # ])
69
69
  #
70
70
  def table(text_or_table, file = nil, line = 0)
71
- location = !file ? Core::Ast::Location.of_caller : Core::Ast::Location.new(file, line)
71
+ location = !file ? Core::Test::Location.of_caller : Core::Test::Location.new(file, line)
72
72
  MultilineArgument::DataTable.from(text_or_table, location)
73
73
  end
74
74
 
@@ -95,16 +95,14 @@ module Cucumber
95
95
 
96
96
  # Mark the matched step as pending.
97
97
  def pending(message = 'TODO')
98
- if block_given?
99
- begin
100
- yield
101
- rescue Exception
102
- raise Pending, message
103
- end
104
- raise Pending, "Expected pending '#{message}' to fail. No Error was raised. No longer pending?"
105
- else
98
+ raise Pending, message unless block_given?
99
+
100
+ begin
101
+ yield
102
+ rescue Exception # rubocop:disable Lint/RescueException
106
103
  raise Pending, message
107
104
  end
105
+ raise Pending, "Expected pending '#{message}' to fail. No Error was raised. No longer pending?"
108
106
  end
109
107
 
110
108
  # Skips this step and the remaining steps in the scenario
@@ -123,8 +121,8 @@ module Cucumber
123
121
  end
124
122
 
125
123
  # Dynamially generate the API module, closuring the dependencies
126
- def self.for(runtime, language)
127
- Module.new do
124
+ def self.for(runtime, language) # rubocop:disable Metrics/MethodLength
125
+ Module.new do # rubocop:disable Metrics/BlockLength
128
126
  def self.extended(object)
129
127
  # wrap the dynamically generated module so that we can document the methods
130
128
  # for yardoc, which doesn't like define_method.
@@ -139,12 +137,12 @@ module Cucumber
139
137
  end
140
138
 
141
139
  define_method(:step) do |name, raw_multiline_arg = nil|
142
- location = Core::Ast::Location.of_caller
140
+ location = Core::Test::Location.of_caller
143
141
  runtime.invoke_dynamic_step(name, MultilineArgument.from(raw_multiline_arg, location))
144
142
  end
145
143
 
146
144
  define_method(:steps) do |steps_text|
147
- location = Core::Ast::Location.of_caller
145
+ location = Core::Test::Location.of_caller
148
146
  runtime.invoke_dynamic_steps(steps_text, language, location)
149
147
  end
150
148
 
@@ -174,7 +172,7 @@ module Cucumber
174
172
  modules += included_modules
175
173
  end
176
174
  modules << stringify_namespaced_modules
177
- format('#<%s:0x%x>', modules.join('+'), self.object_id)
175
+ format('#<%<modules>s:0x%<object_id>x>', modules: modules.join('+'), object_id: object_id)
178
176
  end
179
177
 
180
178
  private
@@ -28,7 +28,7 @@ module Cucumber
28
28
  # Raised if there are 2 or more World blocks.
29
29
  class MultipleWorld < StandardError
30
30
  def initialize(first_proc, second_proc)
31
- message = String.new
31
+ message = String.new # rubocop:disable Style/EmptyLiteral
32
32
  message << "You can only pass a proc to #World once, but it's happening\n"
33
33
  message << "in 2 places:\n\n"
34
34
  message << Glue.backtrace_line(first_proc, 'World') << "\n"
@@ -53,7 +53,8 @@ module Cucumber
53
53
  end
54
54
 
55
55
  def initialize(runtime, configuration)
56
- @runtime, @configuration = runtime, configuration
56
+ @runtime = runtime
57
+ @configuration = configuration
57
58
  @step_definitions = []
58
59
  Glue::Dsl.rb_language = self
59
60
  @world_proc = @world_modules = nil
@@ -63,11 +64,10 @@ module Cucumber
63
64
  end
64
65
 
65
66
  def step_matches(name_to_match)
66
- @step_definitions.reduce([]) do |result, step_definition|
67
+ @step_definitions.each_with_object([]) do |step_definition, result|
67
68
  if (arguments = step_definition.arguments_from(name_to_match))
68
69
  result << StepMatch.new(step_definition, name_to_match, arguments)
69
70
  end
70
- result
71
71
  end
72
72
  end
73
73
 
@@ -96,9 +96,7 @@ module Cucumber
96
96
 
97
97
  @namespaced_world_modules ||= Hash.new { |h, k| h[k] = [] }
98
98
  namespaced_world_modules.each do |namespace, world_module|
99
- unless @namespaced_world_modules[namespace].include?(world_module)
100
- @namespaced_world_modules[namespace] << world_module
101
- end
99
+ @namespaced_world_modules[namespace] << world_module unless @namespaced_world_modules[namespace].include?(world_module)
102
100
  end
103
101
  end
104
102
 
@@ -153,7 +151,7 @@ module Cucumber
153
151
  def create_expression(string_or_regexp)
154
152
  return CucumberExpressions::CucumberExpression.new(string_or_regexp, @parameter_type_registry) if string_or_regexp.is_a?(String)
155
153
  return CucumberExpressions::RegularExpression.new(string_or_regexp, @parameter_type_registry) if string_or_regexp.is_a?(Regexp)
156
- raise ArgumentError.new('Expression must be a String or Regexp')
154
+ raise ArgumentError, 'Expression must be a String or Regexp'
157
155
  end
158
156
 
159
157
  def self.cli_snippet_type_options
@@ -180,7 +178,7 @@ module Cucumber
180
178
  end
181
179
 
182
180
  def self.backtrace_line(proc, name)
183
- location = Cucumber::Core::Ast::Location.from_source_location(*proc.source_location)
181
+ location = Cucumber::Core::Test::Location.from_source_location(*proc.source_location)
184
182
  "#{location}:in `#{name}'"
185
183
  end
186
184
  end
@@ -3,7 +3,7 @@
3
3
  module Cucumber
4
4
  module Glue
5
5
  module Snippet
6
- ARGUMENT_PATTERNS = ['"([^"]*)"', '(\d+)']
6
+ ARGUMENT_PATTERNS = ['"([^"]*)"', '(\d+)'].freeze
7
7
 
8
8
  class Generator
9
9
  def self.register_on(configuration)
@@ -42,7 +42,7 @@ module Cucumber
42
42
  end
43
43
 
44
44
  def self.cli_option_string(type, cucumber_expression_generator)
45
- format('%-7s: %-28s e.g. %s', type, description, example(cucumber_expression_generator))
45
+ format('%<type>-7s: %<description>-28s e.g. %<example>s', type: type, description: description, example: example(cucumber_expression_generator))
46
46
  end
47
47
 
48
48
  private
@@ -61,7 +61,7 @@ module Cucumber
61
61
  end
62
62
 
63
63
  def do_block
64
- do_block = String.new
64
+ do_block = String.new # rubocop:disable Style/EmptyLiteral
65
65
  do_block << "do#{parameters}\n"
66
66
  multiline_argument.append_comment_to(do_block)
67
67
  do_block << " pending # Write code here that turns the phrase above into concrete actions\n"
@@ -72,11 +72,15 @@ module Cucumber
72
72
  def parameters
73
73
  block_args = (0...number_of_arguments).map { |n| "arg#{n + 1}" }
74
74
  multiline_argument.append_block_parameter_to(block_args)
75
- block_args.empty? ? '' : " |#{block_args.join(", ")}|"
75
+ block_args.empty? ? '' : " |#{block_args.join(', ')}|"
76
76
  end
77
77
 
78
- def self.example(cucumber_expression_generator)
79
- new(cucumber_expression_generator, 'Given', 'I have 2 cukes', MultilineArgument::None.new).step
78
+ class << self
79
+ private
80
+
81
+ def example(cucumber_expression_generator)
82
+ new(cucumber_expression_generator, 'Given', 'I have 2 cukes', MultilineArgument::None.new).step
83
+ end
80
84
  end
81
85
  end
82
86
 
@@ -87,11 +91,11 @@ module Cucumber
87
91
 
88
92
  def to_s
89
93
  header = generated_expressions.each_with_index.map do |expr, i|
90
- prefix = i == 0 ? '' : '# '
94
+ prefix = i.zero? ? '' : '# '
91
95
  "#{prefix}#{code_keyword}(\"#{expr.source}\") do#{parameters(expr)}"
92
96
  end.join("\n")
93
97
 
94
- body = String.new
98
+ body = String.new # rubocop:disable Style/EmptyLiteral
95
99
  multiline_argument.append_comment_to(body)
96
100
  body << " pending # Write code here that turns the phrase above into concrete actions\n"
97
101
  body << 'end'
@@ -102,7 +106,7 @@ module Cucumber
102
106
  def parameters(expr)
103
107
  parameter_names = expr.parameter_names
104
108
  multiline_argument.append_block_parameter_to(parameter_names)
105
- parameter_names.empty? ? '' : " |#{parameter_names.join(", ")}|"
109
+ parameter_names.empty? ? '' : " |#{parameter_names.join(', ')}|"
106
110
  end
107
111
 
108
112
  def self.description
@@ -141,11 +145,11 @@ module Cucumber
141
145
  end
142
146
 
143
147
  SNIPPET_TYPES = {
144
- :cucumber_expression => CucumberExpression,
145
- :regexp => Regexp,
146
- :classic => Classic,
147
- :percent => Percent
148
- }
148
+ cucumber_expression: CucumberExpression,
149
+ regexp: Regexp,
150
+ classic: Classic,
151
+ percent: Percent
152
+ }.freeze
149
153
 
150
154
  module MultilineArgumentSnippet
151
155
  def self.new(multiline_argument)
@@ -173,8 +177,7 @@ module Cucumber
173
177
  array << 'string'
174
178
  end
175
179
 
176
- def append_comment_to(string)
177
- end
180
+ def append_comment_to(string); end
178
181
  end
179
182
 
180
183
  class DataTable
@@ -192,11 +195,9 @@ module Cucumber
192
195
  end
193
196
 
194
197
  class None
195
- def append_block_parameter_to(array)
196
- end
198
+ def append_block_parameter_to(array); end
197
199
 
198
- def append_comment_to(string)
199
- end
200
+ def append_comment_to(string); end
200
201
  end
201
202
  end
202
203
  end
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'cucumber/step_match'
4
- require 'cucumber/step_argument'
5
4
  require 'cucumber/core_ext/string'
6
5
  require 'cucumber/glue/invoke_in_world'
7
6
 
@@ -44,21 +43,21 @@ module Cucumber
44
43
  end
45
44
 
46
45
  def patch_location_onto(block)
47
- location = Core::Ast::Location.of_caller(5)
46
+ location = Core::Test::Location.of_caller(5)
48
47
  block.define_singleton_method(:source_location) { [location.file, location.line] }
49
48
  block
50
49
  end
51
50
 
52
51
  def parse_target_proc_from(options)
53
- return lambda { self } unless options.key?(:on)
52
+ return -> { self } unless options.key?(:on)
54
53
  target = options[:on]
55
54
  case target
56
55
  when Proc
57
56
  target
58
57
  when Symbol
59
- lambda { self.send(target) }
58
+ -> { send(target) }
60
59
  else
61
- lambda { raise ArgumentError, 'Target must be a symbol or a proc' }
60
+ -> { raise ArgumentError, 'Target must be a symbol or a proc' }
62
61
  end
63
62
  end
64
63
  end
@@ -67,7 +66,9 @@ module Cucumber
67
66
 
68
67
  def initialize(registry, expression, proc)
69
68
  raise 'No regexp' if expression.is_a?(Regexp)
70
- @registry, @expression, @proc = registry, expression, proc
69
+ @registry = registry
70
+ @expression = expression
71
+ @proc = proc
71
72
  # @registry.available_step_definition(regexp_source, location)
72
73
  end
73
74
 
@@ -92,8 +93,8 @@ module Cucumber
92
93
  end
93
94
 
94
95
  # @api private
95
- def ==(step_definition)
96
- expression.source == step_definition.expression.source
96
+ def ==(other)
97
+ expression.source == other.expression.source
97
98
  end
98
99
 
99
100
  # @api private
@@ -106,12 +107,10 @@ module Cucumber
106
107
  # @api private
107
108
  # TODO: inline this and step definition just be a value object
108
109
  def invoke(args)
109
- begin
110
- InvokeInWorld.cucumber_instance_exec_in(@registry.current_world, true, @expression.to_s, *args, &@proc)
111
- rescue ArityMismatchError => e
112
- e.backtrace.unshift(self.backtrace_line)
113
- raise e
114
- end
110
+ InvokeInWorld.cucumber_instance_exec_in(@registry.current_world, true, @expression.to_s, *args, &@proc)
111
+ rescue ArityMismatchError => e
112
+ e.backtrace.unshift(backtrace_line)
113
+ raise e
115
114
  end
116
115
 
117
116
  # @api private
@@ -131,7 +130,7 @@ module Cucumber
131
130
 
132
131
  # The source location where the step definition can be found
133
132
  def location
134
- @location ||= Cucumber::Core::Ast::Location.from_source_location(*@proc.source_location)
133
+ @location ||= Cucumber::Core::Test::Location.from_source_location(*@proc.source_location)
135
134
  end
136
135
 
137
136
  # @api private