cucumber 10.2.0 → 11.0.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.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/VERSION +1 -1
  4. data/lib/cucumber/cli/configuration.rb +1 -1
  5. data/lib/cucumber/cli/options.rb +3 -18
  6. data/lib/cucumber/cli/profile_loader.rb +2 -2
  7. data/lib/cucumber/cli/rerun_file.rb +1 -1
  8. data/lib/cucumber/cli.rb +3 -0
  9. data/lib/cucumber/configuration.rb +29 -24
  10. data/lib/cucumber/events/envelope.rb +18 -0
  11. data/lib/cucumber/events/test_run_hook_finished.rb +11 -0
  12. data/lib/cucumber/events/test_run_hook_started.rb +11 -0
  13. data/lib/cucumber/events.rb +2 -0
  14. data/lib/cucumber/filters/randomizer.rb +5 -5
  15. data/lib/cucumber/filters/reverser.rb +41 -0
  16. data/lib/cucumber/filters.rb +1 -12
  17. data/lib/cucumber/formatter/ansicolor.rb +3 -0
  18. data/lib/cucumber/formatter/duration_extractor.rb +2 -0
  19. data/lib/cucumber/formatter/html.rb +1 -3
  20. data/lib/cucumber/formatter/junit.rb +1 -28
  21. data/lib/cucumber/formatter/message.rb +1 -0
  22. data/lib/cucumber/formatter/message_builder.rb +133 -29
  23. data/lib/cucumber/formatter/progress.rb +1 -0
  24. data/lib/cucumber/formatter/query/test_case_started_by_test_case.rb +1 -0
  25. data/lib/cucumber/formatter/rerun.rb +76 -32
  26. data/lib/cucumber/formatter/usage.rb +1 -1
  27. data/lib/cucumber/formatter.rb +3 -0
  28. data/lib/cucumber/glue/registry_and_more.rb +27 -14
  29. data/lib/cucumber/glue.rb +3 -0
  30. data/lib/cucumber/multiline_argument/data_table.rb +0 -11
  31. data/lib/cucumber/platform.rb +2 -2
  32. data/lib/cucumber/query.rb +273 -0
  33. data/lib/cucumber/rake/forked_cucumber_runner.rb +57 -0
  34. data/lib/cucumber/rake/in_process_cucumber_runner.rb +27 -0
  35. data/lib/cucumber/rake/task.rb +36 -106
  36. data/lib/cucumber/rake.rb +3 -0
  37. data/lib/cucumber/repository.rb +136 -0
  38. data/lib/cucumber/rspec/disable_option_parser.rb +3 -3
  39. data/lib/cucumber/runtime.rb +1 -0
  40. data/lib/cucumber/step_match.rb +1 -1
  41. data/lib/cucumber.rb +2 -13
  42. metadata +29 -21
  43. data/lib/cucumber/formatter/query/pickle_step_by_test_step.rb +0 -28
  44. data/lib/cucumber/formatter/query/test_run_started.rb +0 -17
  45. data/lib/cucumber/step_definition_light.rb +0 -29
@@ -4,45 +4,60 @@ require 'base64'
4
4
  require 'cucumber/formatter/backtrace_filter'
5
5
  require 'cucumber/formatter/query/hook_by_test_step'
6
6
  require 'cucumber/formatter/query/pickle_by_test'
7
- require 'cucumber/formatter/query/pickle_step_by_test_step'
8
7
  require 'cucumber/formatter/query/step_definitions_by_test_step'
9
8
  require 'cucumber/formatter/query/test_case_started_by_test_case'
10
- require 'cucumber/formatter/query/test_run_started'
9
+
10
+ require 'cucumber/query'
11
11
 
12
12
  module Cucumber
13
13
  module Formatter
14
14
  class MessageBuilder
15
15
  include Cucumber::Messages::Helpers::TimeConversion
16
+ include Io
16
17
 
17
18
  def initialize(config)
18
19
  @config = config
19
20
 
20
21
  @hook_by_test_step = Query::HookByTestStep.new(config)
21
22
  @pickle_by_test = Query::PickleByTest.new(config)
22
- @pickle_step_by_test_step = Query::PickleStepByTestStep.new(config)
23
23
  @step_definitions_by_test_step = Query::StepDefinitionsByTestStep.new(config)
24
24
  @test_case_started_by_test_case = Query::TestCaseStartedByTestCase.new(config)
25
- @test_run_started = Query::TestRunStarted.new(config)
25
+
26
+ @repository = Cucumber::Repository.new
27
+ @query = Cucumber::Query.new(@repository)
28
+
29
+ @test_run_started_id = config.id_generator.new_id
30
+ @test_case_by_step_id = {}
31
+ @pickle_id_step_by_test_step_id = {}
32
+
33
+ # Ensure all handlers for events occur after all ivars are instantiated
26
34
 
27
35
  config.on_event :envelope, &method(:on_envelope)
36
+
37
+ config.on_event :gherkin_source_parsed, &method(:on_gherkin_source_parsed)
28
38
  config.on_event :gherkin_source_read, &method(:on_gherkin_source_read)
39
+
40
+ config.on_event :hook_test_step_created, &method(:on_hook_test_step_created)
41
+
42
+ config.on_event :step_activated, &method(:on_step_activated)
43
+ config.on_event :step_definition_registered, &method(:on_step_definition_registered)
44
+
45
+ # TODO: Handle TestCaseCreated
29
46
  config.on_event :test_case_ready, &method(:on_test_case_ready)
30
- config.on_event :test_run_started, &method(:on_test_run_started)
31
47
  config.on_event :test_case_started, &method(:on_test_case_started)
32
- config.on_event :test_step_started, &method(:on_test_step_started)
33
- config.on_event :test_step_finished, &method(:on_test_step_finished)
34
48
  config.on_event :test_case_finished, &method(:on_test_case_finished)
49
+
50
+ config.on_event :test_run_started, &method(:on_test_run_started)
35
51
  config.on_event :test_run_finished, &method(:on_test_run_finished)
36
- config.on_event :undefined_parameter_type, &method(:on_undefined_parameter_type)
37
52
 
38
- @test_case_by_step_id = {}
39
- @current_test_run_started_id = nil
40
- @current_test_case_started_id = nil
41
- @current_test_step_id = nil
42
- end
53
+ config.on_event :test_run_hook_started, &method(:on_test_run_hook_started)
54
+ config.on_event :test_run_hook_finished, &method(:on_test_run_hook_finished)
43
55
 
44
- def output_message
45
- raise 'To be implemented'
56
+ config.on_event :test_step_created, &method(:on_test_step_created)
57
+ config.on_event :test_step_started, &method(:on_test_step_started)
58
+ config.on_event :test_step_finished, &method(:on_test_step_finished)
59
+
60
+ config.on_event :undefined_parameter_type, &method(:on_undefined_parameter_type)
46
61
  end
47
62
 
48
63
  def attach(src, media_type, filename)
@@ -50,7 +65,8 @@ module Cucumber
50
65
  test_step_id: @current_test_step_id,
51
66
  test_case_started_id: @current_test_case_started_id,
52
67
  media_type: media_type,
53
- file_name: filename
68
+ file_name: filename,
69
+ timestamp: time_to_timestamp(Time.now)
54
70
  }
55
71
 
56
72
  if media_type&.start_with?('text/')
@@ -72,6 +88,10 @@ module Cucumber
72
88
  output_envelope(event.envelope)
73
89
  end
74
90
 
91
+ def on_gherkin_source_parsed(_event)
92
+ # TODO: Handle GherkinSourceParsed
93
+ end
94
+
75
95
  def on_gherkin_source_read(event)
76
96
  message = Cucumber::Messages::Envelope.new(
77
97
  source: Cucumber::Messages::Source.new(
@@ -84,20 +104,29 @@ module Cucumber
84
104
  output_envelope(message)
85
105
  end
86
106
 
87
- def on_test_case_ready(event)
88
- event.test_case.test_steps.each do |step|
89
- @test_case_by_step_id[step.id] = event.test_case
90
- end
107
+ def on_hook_test_step_created(_event)
108
+ # TODO: Handle HookTestStepCreated
109
+ end
91
110
 
111
+ def on_test_case_ready(event)
92
112
  message = Cucumber::Messages::Envelope.new(
93
113
  test_case: Cucumber::Messages::TestCase.new(
94
114
  id: event.test_case.id,
95
115
  pickle_id: @pickle_by_test.pickle_id(event.test_case),
96
116
  test_steps: event.test_case.test_steps.map { |step| test_step_to_message(step) },
97
- test_run_started_id: @current_test_run_started_id
117
+ test_run_started_id: @test_run_started_id
98
118
  )
99
119
  )
100
120
 
121
+ # TODO: This may be a redundant update. But for now we're leaving this in whilst we're in the transitory phase
122
+ @repository.update(message)
123
+
124
+ # TODO: Switch this over to using the Repo Query object -> `test_step_by_id`
125
+ # TODO: The finder in query is `find_test_step_by` (Using +TestStepStarted+ message)
126
+ event.test_case.test_steps.each do |step|
127
+ @test_case_by_step_id[step.id] = event.test_case
128
+ end
129
+
101
130
  output_envelope(message)
102
131
  end
103
132
 
@@ -106,7 +135,9 @@ module Cucumber
106
135
 
107
136
  Cucumber::Messages::TestStep.new(
108
137
  id: step.id,
109
- pickle_step_id: @pickle_step_by_test_step.pickle_step_id(step),
138
+ # TODO: This "fake query" is only used once. It can likely be replace by `find_pickle_step_by` which
139
+ # takes a +TestStep+ message from the repo directly.
140
+ pickle_step_id: @pickle_id_step_by_test_step_id[step.id],
110
141
  step_definition_ids: @step_definitions_by_test_step.step_definition_ids(step),
111
142
  step_match_arguments_lists: step_match_arguments_lists(step)
112
143
  )
@@ -141,7 +172,7 @@ module Cucumber
141
172
  Cucumber::Messages::Group.new(
142
173
  start: group.start,
143
174
  value: group.value,
144
- children: group.children.map { |child| argument_group_to_message(child) }
175
+ children: group.children&.map { |child| argument_group_to_message(child) }
145
176
  )
146
177
  end
147
178
 
@@ -150,12 +181,10 @@ module Cucumber
150
181
  end
151
182
 
152
183
  def on_test_run_started(*)
153
- @current_test_run_started_id = @test_run_started.id
154
-
155
184
  message = Cucumber::Messages::Envelope.new(
156
185
  test_run_started: Cucumber::Messages::TestRunStarted.new(
157
186
  timestamp: time_to_timestamp(Time.now),
158
- id: @current_test_run_started_id
187
+ id: @test_run_started_id
159
188
  )
160
189
  )
161
190
 
@@ -177,6 +206,26 @@ module Cucumber
177
206
  output_envelope(message)
178
207
  end
179
208
 
209
+ def on_test_step_created(event)
210
+ @pickle_id_step_by_test_step_id[event.test_step.id] = event.pickle_step.id
211
+ test_step_to_message(event.test_step)
212
+ # TODO: We need to determine what message to output here (Unsure - Placeholder added)
213
+ # message = Cucumber::Messages::Envelope.new(
214
+ # pickle: {
215
+ # id: '',
216
+ # uri: '',
217
+ # location: nil,
218
+ # name: '',
219
+ # language: '',
220
+ # steps: test_step_to_message(event.test_step),
221
+ # tags: [],
222
+ # ast_node_ids: []
223
+ # }
224
+ # )
225
+ #
226
+ # output_envelope(message)
227
+ end
228
+
180
229
  def on_test_step_started(event)
181
230
  @current_test_step_id = event.test_step.id
182
231
  test_case = @test_case_by_step_id[event.test_step.id]
@@ -238,10 +287,18 @@ module Cucumber
238
287
  end
239
288
 
240
289
  def on_test_case_finished(event)
290
+ test_case_started_id = test_case_started_id(event.test_case)
291
+ test_case_started_message = @repository.test_case_started_by_id[test_case_started_id]
292
+ max_attempts = @config.retry_attempts
293
+ # See "fake query" for reason this is index shifted
294
+ retries_attempted = test_case_started_message.attempt - 1
295
+ will_be_retried = event.result.failed? && (retries_attempted < max_attempts)
296
+
241
297
  message = Cucumber::Messages::Envelope.new(
242
298
  test_case_finished: Cucumber::Messages::TestCaseFinished.new(
243
- test_case_started_id: test_case_started_id(event.test_case),
244
- timestamp: time_to_timestamp(Time.now)
299
+ test_case_started_id: test_case_started_id,
300
+ timestamp: time_to_timestamp(Time.now),
301
+ will_be_retried: will_be_retried
245
302
  )
246
303
  )
247
304
 
@@ -253,7 +310,54 @@ module Cucumber
253
310
  test_run_finished: Cucumber::Messages::TestRunFinished.new(
254
311
  timestamp: time_to_timestamp(Time.now),
255
312
  success: event.success,
256
- test_run_started_id: @current_test_run_started_id
313
+ test_run_started_id: @test_run_started_id
314
+ )
315
+ )
316
+
317
+ output_envelope(message)
318
+ end
319
+
320
+ def on_step_activated(event)
321
+ # TODO: Handle StepActivated
322
+ end
323
+
324
+ def on_step_definition_registered(event)
325
+ output_envelope(event.step_definition.to_envelope)
326
+ end
327
+
328
+ def on_test_run_hook_started(event)
329
+ @current_test_run_hook_started_id = @config.id_generator.new_id
330
+
331
+ message = Cucumber::Messages::Envelope.new(
332
+ test_run_hook_started: Cucumber::Messages::TestRunHookStarted.new(
333
+ id: @current_test_run_hook_started_id,
334
+ hook_id: event.hook.id,
335
+ test_run_started_id: @test_run_started_id,
336
+ timestamp: time_to_timestamp(Time.now)
337
+ )
338
+ )
339
+
340
+ output_envelope(message)
341
+ end
342
+
343
+ def on_test_run_hook_finished(event)
344
+ result = event.test_result
345
+ result_message = result.to_message
346
+
347
+ if result.failed?
348
+ result_message = Cucumber::Messages::TestStepResult.new(
349
+ status: result_message.status,
350
+ duration: result_message.duration,
351
+ message: create_error_message(result.exception),
352
+ exception: create_exception_object(result, result.exception)
353
+ )
354
+ end
355
+
356
+ message = Cucumber::Messages::Envelope.new(
357
+ test_run_hook_finished: Cucumber::Messages::TestRunHookFinished.new(
358
+ test_run_hook_started_id: @current_test_run_hook_started_id,
359
+ timestamp: time_to_timestamp(Time.now),
360
+ result: result_message
257
361
  )
258
362
  )
259
363
 
@@ -94,6 +94,7 @@ module Cucumber
94
94
  CHARS = {
95
95
  passed: '.',
96
96
  failed: 'F',
97
+ ambiguous: 'A',
97
98
  undefined: 'U',
98
99
  pending: 'P',
99
100
  skipped: '-'
@@ -35,6 +35,7 @@ module Cucumber
35
35
  end
36
36
 
37
37
  def on_test_case_started(event)
38
+ # TODO: LH - Apr '26 -> Clarify if this should start with attempt 1 or attempt 0
38
39
  @attempts_by_test_case_id[event.test_case.id] += 1
39
40
  @test_case_started_id_by_test_case_id[event.test_case.id] = @config.id_generator.new_id
40
41
  end
@@ -1,52 +1,96 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'cucumber/formatter/io'
4
+ require 'cucumber/formatter/message_builder'
4
5
 
5
6
  module Cucumber
6
7
  module Formatter
7
- class Rerun
8
- include Formatter::Io
9
-
8
+ class Rerun < MessageBuilder
10
9
  def initialize(config)
11
10
  @io = ensure_io(config.out_stream, config.error_stream)
12
- @config = config
13
- @failures = {}
14
- config.on_event :test_case_finished do |event|
15
- test_case, result = *event.attributes
16
- if @config.strict.strict?(:flaky)
17
- next if result.ok?(strict: @config.strict)
18
-
19
- add_to_failures(test_case)
20
- else
21
- unless @latest_failed_test_case.nil?
22
- if @latest_failed_test_case != test_case
23
- add_to_failures(@latest_failed_test_case)
24
- @latest_failed_test_case = nil
25
- elsif result.ok?(strict: @config.strict)
26
- @latest_failed_test_case = nil
27
- end
28
- end
29
- @latest_failed_test_case = test_case unless result.ok?(strict: @config.strict)
11
+ super(config)
12
+ end
13
+
14
+ def output_envelope(envelope)
15
+ @repository.update(envelope)
16
+ finish_report if envelope.test_run_finished
17
+ end
18
+
19
+ private
20
+
21
+ def finish_report
22
+ @query.find_all_test_case_started.each do |test_case|
23
+ status = @query.find_most_severe_test_step_result_by(test_case).status
24
+ # RULE: Don't log test cases without a pickle (Unsure what these could be?)
25
+ pickle = @query.find_pickle_by(test_case)
26
+ next if pickle.nil?
27
+
28
+ # RULE: (Configuration specific)
29
+ # -> If the test case has already been logged (And so we're retrying), we remove prior references of failures
30
+ if passing?(test_case) && !rerun_flaky_tests?
31
+ uri_and_location_hash[pickle.uri].delete(pickle.location.line)
32
+ next
33
+ end
34
+
35
+ # RULE: (Configuration specific - to be amended once CCK conformance is finalised)
36
+ # -> If the strict configuration permits the result - handle it accordingly
37
+ if status == 'UNDEFINED' && !@config.strict.strict?(:undefined)
38
+ Cucumber.deprecate(
39
+ 'The strict configuration in cucumber is going away and moving towards a standardised set of behaviours',
40
+ '--strict=undefined',
41
+ '12.0.0'
42
+ )
43
+ next
44
+ end
45
+
46
+ if status == 'PENDING' && !@config.strict.strict?(:pending)
47
+ Cucumber.deprecate(
48
+ 'The strict configuration in cucumber is going away and moving towards a standardised set of behaviours',
49
+ '--strict=pending',
50
+ '12.0.0'
51
+ )
52
+ next
30
53
  end
54
+
55
+ # RULE: Passing test cases are not considered failures (Don't log these)
56
+ next if passing?(test_case)
57
+
58
+ # RULE: Skipped test cases are not considered failures (on their own, don't log these)
59
+ next if skipped?(test_case)
60
+
61
+ # RULE: Before logging a failure, ensure we are not on a retried test case (Don't log a retry multiple times)
62
+ next if test_case.attempt > 1
63
+
64
+ # Log the failure if every other skip rule has not been met, and the failure has not already been logged
65
+ uri_and_location_hash[pickle.uri] << pickle.location.line
31
66
  end
32
- config.on_event :test_run_finished do
33
- add_to_failures(@latest_failed_test_case) unless @latest_failed_test_case.nil?
34
- next if @failures.empty?
35
67
 
36
- @io.print file_failures.join("\n")
68
+ # Generate the final output from the logged failures to be formatted in the io output
69
+ @io.print(failure_array.join("\n"))
70
+ end
71
+
72
+ def failure_array
73
+ uri_and_location_hash.filter_map do |uri, lines|
74
+ "#{uri}:#{lines.join(':')}" if lines.any?
37
75
  end
38
76
  end
39
77
 
40
- private
78
+ def uri_and_location_hash
79
+ @uri_and_location_hash ||= Hash.new { |hash, key| hash[key] = Set.new }
80
+ end
81
+
82
+ def rerun_flaky_tests?
83
+ @config.strict.strict?(:flaky)
84
+ end
41
85
 
42
- def file_failures
43
- @failures.map { |file, lines| [file, lines].join(':') }
86
+ def passing?(test_case_started)
87
+ most_severe_test_step_result = @query.find_most_severe_test_step_result_by(test_case_started)
88
+ most_severe_test_step_result.status == Cucumber::Messages::TestStepResultStatus::PASSED
44
89
  end
45
90
 
46
- def add_to_failures(test_case)
47
- location = test_case.location
48
- @failures[location.file] ||= []
49
- @failures[location.file] << location.lines.max unless @failures[location.file].include?(location.lines.max)
91
+ def skipped?(test_case_started)
92
+ most_severe_test_step_result = @query.find_most_severe_test_step_result_by(test_case_started)
93
+ most_severe_test_step_result.status == Cucumber::Messages::TestStepResultStatus::SKIPPED
50
94
  end
51
95
  end
52
96
  end
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'cucumber/formatter/progress'
4
- require 'cucumber/step_definition_light'
5
4
  require 'cucumber/formatter/console'
6
5
 
7
6
  module Cucumber
8
7
  module Formatter
9
8
  class Usage < Progress
10
9
  include Console
10
+
11
11
  class StepDefKey
12
12
  attr_accessor :mean_duration, :status
13
13
  attr_reader :regexp_source, :location
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ Dir["#{File.dirname(__FILE__)}/formatter/*.rb"].map(&method(:require))
@@ -13,7 +13,6 @@ require 'cucumber/glue/world_factory'
13
13
  require 'cucumber/gherkin/i18n'
14
14
  require 'multi_test'
15
15
  require 'cucumber/step_match'
16
- require 'cucumber/step_definition_light'
17
16
  require 'cucumber/events/step_definition_registered'
18
17
 
19
18
  module Cucumber
@@ -100,7 +99,6 @@ module Cucumber
100
99
  step_definition = StepDefinition.new(@configuration.id_generator.new_id, self, string_or_regexp, proc_or_sym, options)
101
100
  @step_definitions << step_definition
102
101
  @configuration.notify :step_definition_registered, step_definition
103
- @configuration.notify :envelope, step_definition.to_envelope
104
102
  step_definition
105
103
  rescue Cucumber::CucumberExpressions::UndefinedParameterTypeError => e
106
104
  # TODO: add a way to extract the parameter type directly from the error.
@@ -128,12 +126,7 @@ module Cucumber
128
126
  return unless File.extname(code_file) == '.rb'
129
127
 
130
128
  # This will cause self.add_step_definition, self.add_hook, and self.define_parameter_type to be called from Glue::Dsl
131
-
132
- if Cucumber.use_legacy_autoloader
133
- load File.expand_path(code_file)
134
- else
135
- require File.expand_path(code_file)
136
- end
129
+ require File.expand_path(code_file)
137
130
  end
138
131
 
139
132
  def begin_scenario(test_case)
@@ -155,13 +148,13 @@ module Cucumber
155
148
 
156
149
  def before_all
157
150
  hooks[:before_all].each do |hook|
158
- hook.invoke('BeforeAll', [])
151
+ invoke_run_hook(hook, 'BeforeAll')
159
152
  end
160
153
  end
161
154
 
162
155
  def after_all
163
156
  hooks[:after_all].each do |hook|
164
- hook.invoke('AfterAll', [])
157
+ invoke_run_hook(hook, 'AfterAll')
165
158
  end
166
159
  end
167
160
 
@@ -187,6 +180,18 @@ module Cucumber
187
180
 
188
181
  private
189
182
 
183
+ def invoke_run_hook(hook, pseudo_method)
184
+ @configuration.notify(:test_run_hook_started, hook)
185
+ timer = Core::Test::Timer.new.start
186
+ begin
187
+ hook.invoke(pseudo_method, [])
188
+ @configuration.notify(:test_run_hook_finished, hook, Core::Test::Result::Passed.new(timer.duration))
189
+ rescue StandardError => e
190
+ @configuration.notify(:test_run_hook_finished, hook, Core::Test::Result::Failed.new(timer.duration, e))
191
+ raise
192
+ end
193
+ end
194
+
190
195
  def parameter_type_envelope(parameter_type)
191
196
  # TODO: should this be moved to Cucumber::Expression::ParameterType#to_envelope ??
192
197
  # Note: that would mean that cucumber-expression would depend on cucumber-messages
@@ -197,14 +202,22 @@ module Cucumber
197
202
  regular_expressions: parameter_type.regexps.map(&:to_s),
198
203
  prefer_for_regular_expression_match: parameter_type.prefer_for_regexp_match,
199
204
  use_for_snippets: parameter_type.use_for_snippets,
200
- source_reference: Cucumber::Messages::SourceReference.new(
201
- uri: parameter_type.transformer.source_location[0],
202
- location: Cucumber::Messages::Location.new(line: parameter_type.transformer.source_location[1])
203
- )
205
+ source_reference: source_reference_for(parameter_type.transformer)
204
206
  )
205
207
  )
206
208
  end
207
209
 
210
+ def source_reference_for(transformer)
211
+ # #source_location may return nil if no definition was found
212
+ # This is the case for transformers created using method(sym) or similar
213
+ return nil if transformer.source_location.nil?
214
+
215
+ Cucumber::Messages::SourceReference.new(
216
+ uri: transformer.source_location[0],
217
+ location: Cucumber::Messages::Location.new(line: transformer.source_location[1])
218
+ )
219
+ end
220
+
208
221
  def hooks
209
222
  @hooks ||= Hash.new { |h, k| h[k] = [] }
210
223
  end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ Dir["#{File.dirname(__FILE__)}/glue/*.rb"].map(&method(:require))
@@ -364,17 +364,6 @@ module Cucumber
364
364
  raise %(The table must have exactly #{width} columns) unless raw[0].size == width
365
365
  end
366
366
 
367
- # TODO: remove the below function if it's not actually being used.
368
- # Nothing else in this repo calls it.
369
- def text?(text)
370
- Cucumber.deprecate(
371
- 'This method is no longer supported for checking text',
372
- '#text?',
373
- '11.0.0'
374
- )
375
- raw.flatten.compact.detect { |cell_value| cell_value.index(text) }
376
- end
377
-
378
367
  def cells_rows
379
368
  @rows ||= cell_matrix.map do |cell_row|
380
369
  Cells.new(self, cell_row)
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'rbconfig'
4
- require 'cucumber/core/platform'
5
4
 
6
5
  module Cucumber
7
6
  VERSION = File.read(File.expand_path('../../VERSION', __dir__)).strip
8
7
  BINARY = File.expand_path("#{File.dirname(__FILE__)}/../../bin/cucumber")
9
- LIBDIR = File.expand_path("#{File.dirname(__FILE__)}/../../lib")
10
8
  RUBY_BINARY = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])
9
+ JRUBY = defined?(JRUBY_VERSION)
10
+ WINDOWS = RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
11
11
 
12
12
  class << self
13
13
  attr_writer :use_full_backtrace