From f267a9893dbee9f8bac43e85cf7b2a78dc28efe2 Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Wed, 15 Apr 2026 19:05:49 +0100 Subject: [PATCH 01/15] Initial strawman to remove inheritance --- lib/cucumber/events/envelope.rb | 47 +++++++++++++++++++++++++++++ lib/cucumber/events/envelope_old.rb | 29 ++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 lib/cucumber/events/envelope_old.rb diff --git a/lib/cucumber/events/envelope.rb b/lib/cucumber/events/envelope.rb index ab2fbf399..76b07abe3 100644 --- a/lib/cucumber/events/envelope.rb +++ b/lib/cucumber/events/envelope.rb @@ -7,6 +7,53 @@ module Events class Envelope < Core::Event.new(:envelope) attr_reader :envelope + # @return [Symbol] the underscored name of the class to be used as the key in an event registry + def self.event_id + underscore(name.split('::').last).to_sym + end + + def self.underscore(string) + string + .to_s + .gsub('::', '/') + .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2') + .gsub(/([a-z\d])([A-Z])/, '\1_\2') + .tr('-', '_') + .downcase + end + + def self.new(*events) + # Use normal constructor for subclasses of Event + return super if ancestors.index(Event).positive? + + Class.new(Event) do + # NB: We need to use metaprogramming here instead of direct variable obtainment + # because JRuby does not guarantee the order in which variables are defined is equivalent + # to the order in which they are obtainable + # + # See https://github.com/jruby/jruby/issues/7988 for more info + attr_reader(*events) + + define_method(:initialize) do |*attributes| + events.zip(attributes) do |name, value| + instance_variable_set(:"@#{name}", value) + end + end + + define_method(:attributes) do + events.map { |var| instance_variable_get(:"@#{var}") } + end + + define_method(:to_h) do + events.zip(attributes).to_h + end + + def event_id + self.class.event_id + end + end + end + def inspect "Envelope Event -> Message Type: #{type}}" end diff --git a/lib/cucumber/events/envelope_old.rb b/lib/cucumber/events/envelope_old.rb new file mode 100644 index 000000000..bb54e3696 --- /dev/null +++ b/lib/cucumber/events/envelope_old.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +require 'cucumber/core/events' + +module Cucumber + module Events + class EnvelopeOld < Core::Event.new(:envelope) + attr_reader :envelope + + def inspect + "Envelope Event -> Message Type: #{type}}" + end + + def to_s + inspect + end + + private + + def type + envelope.instance_variables.detect { |message| !envelope.send(name_of(message)).nil? } + end + + def name_of(message) + message.to_s.delete('@') + end + end + end +end From ecd1b01e6c991ba221de6374cd7ed4950da4c85e Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Wed, 15 Apr 2026 19:17:27 +0100 Subject: [PATCH 02/15] WIP: Use a little bit of refactoring to tidy up items --- lib/cucumber/events/envelope.rb | 54 ++++++++++----------------------- 1 file changed, 16 insertions(+), 38 deletions(-) diff --git a/lib/cucumber/events/envelope.rb b/lib/cucumber/events/envelope.rb index 76b07abe3..ba8e29cb0 100644 --- a/lib/cucumber/events/envelope.rb +++ b/lib/cucumber/events/envelope.rb @@ -4,54 +4,32 @@ module Cucumber module Events - class Envelope < Core::Event.new(:envelope) + class Envelope attr_reader :envelope # @return [Symbol] the underscored name of the class to be used as the key in an event registry def self.event_id - underscore(name.split('::').last).to_sym + :envelope end - def self.underscore(string) - string - .to_s - .gsub('::', '/') - .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2') - .gsub(/([a-z\d])([A-Z])/, '\1_\2') - .tr('-', '_') - .downcase + def initialize(envelope) + @envelope = envelope end - def self.new(*events) - # Use normal constructor for subclasses of Event - return super if ancestors.index(Event).positive? - - Class.new(Event) do - # NB: We need to use metaprogramming here instead of direct variable obtainment - # because JRuby does not guarantee the order in which variables are defined is equivalent - # to the order in which they are obtainable - # - # See https://github.com/jruby/jruby/issues/7988 for more info - attr_reader(*events) - - define_method(:initialize) do |*attributes| - events.zip(attributes) do |name, value| - instance_variable_set(:"@#{name}", value) - end - end - - define_method(:attributes) do - events.map { |var| instance_variable_get(:"@#{var}") } - end + # Here just is an array of each method defined as your readers + def attributes + [envelope] + to_h.map { |_k, v| v } + end - define_method(:to_h) do - events.zip(attributes).to_h - end + def to_h + { + envelope: envelope + } + end - def event_id - self.class.event_id - end - end + def event_id + self.class.event_id end def inspect From b376a0596ddcbcef9184e12a7e89022984cb9a1c Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Wed, 15 Apr 2026 19:28:14 +0100 Subject: [PATCH 03/15] Further proof / strawman on duplicate code that can be removed --- lib/cucumber/events/gherkin_source_parsed.rb | 4 ++-- lib/cucumber/events/gherkin_source_read.rb | 10 +++++----- lib/cucumber/events/hook_test_step_created.rb | 2 +- lib/cucumber/events/step_activated.rb | 16 ++++++++-------- lib/cucumber/events/test_case_started.rb | 4 ++-- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/lib/cucumber/events/gherkin_source_parsed.rb b/lib/cucumber/events/gherkin_source_parsed.rb index c5d7d6691..28f729f2a 100644 --- a/lib/cucumber/events/gherkin_source_parsed.rb +++ b/lib/cucumber/events/gherkin_source_parsed.rb @@ -6,8 +6,8 @@ module Cucumber module Events # Fired after we've parsed the contents of a feature file class GherkinSourceParsed < Core::Event.new(:gherkin_document) - # The Gherkin Ast - attr_reader :gherkin_document + # # The Gherkin Ast + # attr_reader :gherkin_document end end end diff --git a/lib/cucumber/events/gherkin_source_read.rb b/lib/cucumber/events/gherkin_source_read.rb index 5ff1ab282..efe6dc7b7 100644 --- a/lib/cucumber/events/gherkin_source_read.rb +++ b/lib/cucumber/events/gherkin_source_read.rb @@ -6,11 +6,11 @@ module Cucumber module Events # Fired after we've read in the contents of a feature file class GherkinSourceRead < Core::Event.new(:path, :body) - # The path to the file - attr_reader :path - - # The raw Gherkin source - attr_reader :body + # # The path to the file + # attr_reader :path + # + # # The raw Gherkin source + # attr_reader :body end end end diff --git a/lib/cucumber/events/hook_test_step_created.rb b/lib/cucumber/events/hook_test_step_created.rb index 4e1596dcb..f061000ab 100644 --- a/lib/cucumber/events/hook_test_step_created.rb +++ b/lib/cucumber/events/hook_test_step_created.rb @@ -6,7 +6,7 @@ module Cucumber module Events # Event fired when a step is created from a hook class HookTestStepCreated < Core::Event.new(:test_step, :hook) - attr_reader :test_step, :hook + # attr_reader :test_step, :hook end end end diff --git a/lib/cucumber/events/step_activated.rb b/lib/cucumber/events/step_activated.rb index e9a26ce4e..247c2208d 100644 --- a/lib/cucumber/events/step_activated.rb +++ b/lib/cucumber/events/step_activated.rb @@ -6,15 +6,15 @@ module Cucumber module Events # Event fired when a step is activated class StepActivated < Core::Event.new(:test_step, :step_match) - # The test step that was matched. + # # The test step that was matched. + # # + # # @return [Cucumber::Core::Test::Step] + # attr_reader :test_step # - # @return [Cucumber::Core::Test::Step] - attr_reader :test_step - - # Information about the matching definition. - # - # @return [Cucumber::StepMatch] - attr_reader :step_match + # # Information about the matching definition. + # # + # # @return [Cucumber::StepMatch] + # attr_reader :step_match end end end diff --git a/lib/cucumber/events/test_case_started.rb b/lib/cucumber/events/test_case_started.rb index 75e247286..2f131f25d 100644 --- a/lib/cucumber/events/test_case_started.rb +++ b/lib/cucumber/events/test_case_started.rb @@ -6,8 +6,8 @@ module Cucumber module Events # Signals that a {Cucumber::Core::Test::Case} is about to be executed class TestCaseStarted < Core::Events::TestCaseStarted - # @return [Cucumber::Core::Test::Case] the test case to be executed - attr_reader :test_case + # # @return [Cucumber::Core::Test::Case] the test case to be executed + # attr_reader :test_case end end end From 1033278fce1f02c5149d341af6afe4a219a02a64 Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Fri, 24 Apr 2026 00:15:02 +0100 Subject: [PATCH 04/15] Remove attributes for envelope event - just lean on hashified response --- lib/cucumber/events/envelope.rb | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lib/cucumber/events/envelope.rb b/lib/cucumber/events/envelope.rb index ba8e29cb0..7967f3f13 100644 --- a/lib/cucumber/events/envelope.rb +++ b/lib/cucumber/events/envelope.rb @@ -16,12 +16,6 @@ def initialize(envelope) @envelope = envelope end - # Here just is an array of each method defined as your readers - def attributes - [envelope] - to_h.map { |_k, v| v } - end - def to_h { envelope: envelope From fe43dd80f41520cf4e62453ce9436f7dcf4e9046 Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Fri, 24 Apr 2026 00:19:55 +0100 Subject: [PATCH 05/15] Refactor out 3 event inheritances to use defined classes --- lib/cucumber/events/envelope_old.rb | 29 ---------------- lib/cucumber/events/gherkin_source_parsed.rb | 23 +++++++++++-- lib/cucumber/events/gherkin_source_read.rb | 33 +++++++++++++++---- lib/cucumber/events/hook_test_step_created.rb | 25 ++++++++++++-- 4 files changed, 71 insertions(+), 39 deletions(-) delete mode 100644 lib/cucumber/events/envelope_old.rb diff --git a/lib/cucumber/events/envelope_old.rb b/lib/cucumber/events/envelope_old.rb deleted file mode 100644 index bb54e3696..000000000 --- a/lib/cucumber/events/envelope_old.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -require 'cucumber/core/events' - -module Cucumber - module Events - class EnvelopeOld < Core::Event.new(:envelope) - attr_reader :envelope - - def inspect - "Envelope Event -> Message Type: #{type}}" - end - - def to_s - inspect - end - - private - - def type - envelope.instance_variables.detect { |message| !envelope.send(name_of(message)).nil? } - end - - def name_of(message) - message.to_s.delete('@') - end - end - end -end diff --git a/lib/cucumber/events/gherkin_source_parsed.rb b/lib/cucumber/events/gherkin_source_parsed.rb index 28f729f2a..521848f93 100644 --- a/lib/cucumber/events/gherkin_source_parsed.rb +++ b/lib/cucumber/events/gherkin_source_parsed.rb @@ -5,9 +5,28 @@ module Cucumber module Events # Fired after we've parsed the contents of a feature file - class GherkinSourceParsed < Core::Event.new(:gherkin_document) + class GherkinSourceParsed # # The Gherkin Ast - # attr_reader :gherkin_document + attr_reader :gherkin_document + + # @return [Symbol] the underscored name of the class to be used as the key in an event registry + def self.event_id + :gherkin_document + end + + def initialize(gherkin_document) + @gherkin_document = gherkin_document + end + + def to_h + { + gherkin_document: gherkin_document + } + end + + def event_id + self.class.event_id + end end end end diff --git a/lib/cucumber/events/gherkin_source_read.rb b/lib/cucumber/events/gherkin_source_read.rb index efe6dc7b7..3159d53f8 100644 --- a/lib/cucumber/events/gherkin_source_read.rb +++ b/lib/cucumber/events/gherkin_source_read.rb @@ -5,12 +5,33 @@ module Cucumber module Events # Fired after we've read in the contents of a feature file - class GherkinSourceRead < Core::Event.new(:path, :body) - # # The path to the file - # attr_reader :path - # - # # The raw Gherkin source - # attr_reader :body + class GherkinSourceRead + # The path to the file + attr_reader :path + + # The raw Gherkin source + attr_reader :body + + # @return [Symbol] the underscored name of the class to be used as the key in an event registry + def self.event_id + :gherkin_source_read + end + + def initialize(path, body) + @path = path + @body = body + end + + def to_h + { + path: path, + body: body + } + end + + def event_id + self.class.event_id + end end end end diff --git a/lib/cucumber/events/hook_test_step_created.rb b/lib/cucumber/events/hook_test_step_created.rb index f061000ab..83541d431 100644 --- a/lib/cucumber/events/hook_test_step_created.rb +++ b/lib/cucumber/events/hook_test_step_created.rb @@ -5,8 +5,29 @@ module Cucumber module Events # Event fired when a step is created from a hook - class HookTestStepCreated < Core::Event.new(:test_step, :hook) - # attr_reader :test_step, :hook + class HookTestStepCreated + attr_reader :test_step, :hook + + # @return [Symbol] the underscored name of the class to be used as the key in an event registry + def self.event_id + :hook_test_step_created + end + + def initialize(test_step, hook) + @test_step = test_step + @hook = hook + end + + def to_h + { + test_step: test_step, + hook: hook + } + end + + def event_id + self.class.event_id + end end end end From 4503c456de8e0931fb256f75c0757e3358f55eae Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Fri, 24 Apr 2026 00:20:50 +0100 Subject: [PATCH 06/15] Fix event id --- lib/cucumber/events/gherkin_source_parsed.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cucumber/events/gherkin_source_parsed.rb b/lib/cucumber/events/gherkin_source_parsed.rb index 521848f93..e14320509 100644 --- a/lib/cucumber/events/gherkin_source_parsed.rb +++ b/lib/cucumber/events/gherkin_source_parsed.rb @@ -11,7 +11,7 @@ class GherkinSourceParsed # @return [Symbol] the underscored name of the class to be used as the key in an event registry def self.event_id - :gherkin_document + :gherkin_source_parsed end def initialize(gherkin_document) From 5202bf036e79d5bc547da0f21d6d1275e7068587 Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Fri, 24 Apr 2026 00:25:27 +0100 Subject: [PATCH 07/15] Refactor to use new base event --- lib/cucumber/events/base_event_new.rb | 20 ++++++++++++++++++++ lib/cucumber/events/envelope.rb | 15 +++------------ lib/cucumber/events/gherkin_source_parsed.rb | 13 ++----------- lib/cucumber/events/gherkin_source_read.rb | 14 ++------------ 4 files changed, 27 insertions(+), 35 deletions(-) create mode 100644 lib/cucumber/events/base_event_new.rb diff --git a/lib/cucumber/events/base_event_new.rb b/lib/cucumber/events/base_event_new.rb new file mode 100644 index 000000000..f2e0d2ee6 --- /dev/null +++ b/lib/cucumber/events/base_event_new.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +module Cucumber + module Events + class BaseEventNew + # @return [Symbol] the underscored name of the class to be used as the key in an event registry + def self.event_id + raise 'Must be implemented in subclass' + end + + def to_h + instance_variables.to_h { |variable_name| [variable_name[1..].to_sym, instance_variable_get(variable_name)] } + end + + def event_id + self.class.event_id + end + end + end +end diff --git a/lib/cucumber/events/envelope.rb b/lib/cucumber/events/envelope.rb index 7967f3f13..c94525949 100644 --- a/lib/cucumber/events/envelope.rb +++ b/lib/cucumber/events/envelope.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true -require 'cucumber/core/events' +require_relative 'base_event_new' module Cucumber module Events - class Envelope + class Envelope < BaseEventNew attr_reader :envelope # @return [Symbol] the underscored name of the class to be used as the key in an event registry @@ -14,16 +14,7 @@ def self.event_id def initialize(envelope) @envelope = envelope - end - - def to_h - { - envelope: envelope - } - end - - def event_id - self.class.event_id + super() end def inspect diff --git a/lib/cucumber/events/gherkin_source_parsed.rb b/lib/cucumber/events/gherkin_source_parsed.rb index e14320509..c422264c3 100644 --- a/lib/cucumber/events/gherkin_source_parsed.rb +++ b/lib/cucumber/events/gherkin_source_parsed.rb @@ -5,7 +5,7 @@ module Cucumber module Events # Fired after we've parsed the contents of a feature file - class GherkinSourceParsed + class GherkinSourceParsed < BaseEventNew # # The Gherkin Ast attr_reader :gherkin_document @@ -16,16 +16,7 @@ def self.event_id def initialize(gherkin_document) @gherkin_document = gherkin_document - end - - def to_h - { - gherkin_document: gherkin_document - } - end - - def event_id - self.class.event_id + super() end end end diff --git a/lib/cucumber/events/gherkin_source_read.rb b/lib/cucumber/events/gherkin_source_read.rb index 3159d53f8..80ec3fdec 100644 --- a/lib/cucumber/events/gherkin_source_read.rb +++ b/lib/cucumber/events/gherkin_source_read.rb @@ -5,7 +5,7 @@ module Cucumber module Events # Fired after we've read in the contents of a feature file - class GherkinSourceRead + class GherkinSourceRead < BaseEventNew # The path to the file attr_reader :path @@ -20,17 +20,7 @@ def self.event_id def initialize(path, body) @path = path @body = body - end - - def to_h - { - path: path, - body: body - } - end - - def event_id - self.class.event_id + super() end end end From 0af335c9d979b70004af2a4434cc0f6da4f2ab7f Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Fri, 24 Apr 2026 00:28:51 +0100 Subject: [PATCH 08/15] Begin testing a few more events being switched over to new base class --- lib/cucumber/events/envelope.rb | 3 +- lib/cucumber/events/gherkin_source_parsed.rb | 3 +- lib/cucumber/events/gherkin_source_read.rb | 3 +- lib/cucumber/events/hook_test_step_created.rb | 17 +++-------- lib/cucumber/events/step_activated.rb | 30 ++++++++++++------- .../events/step_definition_registered.rb | 16 ++++++++-- lib/cucumber/events/test_case_created.rb | 14 ++++++++- 7 files changed, 56 insertions(+), 30 deletions(-) diff --git a/lib/cucumber/events/envelope.rb b/lib/cucumber/events/envelope.rb index c94525949..03e40475a 100644 --- a/lib/cucumber/events/envelope.rb +++ b/lib/cucumber/events/envelope.rb @@ -7,7 +7,8 @@ module Events class Envelope < BaseEventNew attr_reader :envelope - # @return [Symbol] the underscored name of the class to be used as the key in an event registry + # The underscored name of the class to be used as the key in an event registry + # @return [Symbol] def self.event_id :envelope end diff --git a/lib/cucumber/events/gherkin_source_parsed.rb b/lib/cucumber/events/gherkin_source_parsed.rb index c422264c3..276a2586b 100644 --- a/lib/cucumber/events/gherkin_source_parsed.rb +++ b/lib/cucumber/events/gherkin_source_parsed.rb @@ -9,7 +9,8 @@ class GherkinSourceParsed < BaseEventNew # # The Gherkin Ast attr_reader :gherkin_document - # @return [Symbol] the underscored name of the class to be used as the key in an event registry + # The underscored name of the class to be used as the key in an event registry + # @return [Symbol] def self.event_id :gherkin_source_parsed end diff --git a/lib/cucumber/events/gherkin_source_read.rb b/lib/cucumber/events/gherkin_source_read.rb index 80ec3fdec..4d66498c6 100644 --- a/lib/cucumber/events/gherkin_source_read.rb +++ b/lib/cucumber/events/gherkin_source_read.rb @@ -12,7 +12,8 @@ class GherkinSourceRead < BaseEventNew # The raw Gherkin source attr_reader :body - # @return [Symbol] the underscored name of the class to be used as the key in an event registry + # The underscored name of the class to be used as the key in an event registry + # @return [Symbol] def self.event_id :gherkin_source_read end diff --git a/lib/cucumber/events/hook_test_step_created.rb b/lib/cucumber/events/hook_test_step_created.rb index 83541d431..9a1678ed1 100644 --- a/lib/cucumber/events/hook_test_step_created.rb +++ b/lib/cucumber/events/hook_test_step_created.rb @@ -5,10 +5,11 @@ module Cucumber module Events # Event fired when a step is created from a hook - class HookTestStepCreated + class HookTestStepCreated < BaseEventNew attr_reader :test_step, :hook - # @return [Symbol] the underscored name of the class to be used as the key in an event registry + # The underscored name of the class to be used as the key in an event registry + # @return [Symbol] def self.event_id :hook_test_step_created end @@ -16,17 +17,7 @@ def self.event_id def initialize(test_step, hook) @test_step = test_step @hook = hook - end - - def to_h - { - test_step: test_step, - hook: hook - } - end - - def event_id - self.class.event_id + super() end end end diff --git a/lib/cucumber/events/step_activated.rb b/lib/cucumber/events/step_activated.rb index 247c2208d..af38122de 100644 --- a/lib/cucumber/events/step_activated.rb +++ b/lib/cucumber/events/step_activated.rb @@ -5,16 +5,26 @@ module Cucumber module Events # Event fired when a step is activated - class StepActivated < Core::Event.new(:test_step, :step_match) - # # The test step that was matched. - # # - # # @return [Cucumber::Core::Test::Step] - # attr_reader :test_step - # - # # Information about the matching definition. - # # - # # @return [Cucumber::StepMatch] - # attr_reader :step_match + class StepActivated < BaseEventNew + # The test step that was matched. + # @return [Cucumber::Core::Test::Step] + attr_reader :test_step + + # Information about the matching definition. + # @return [Cucumber::StepMatch] + attr_reader :step_match + + # The underscored name of the class to be used as the key in an event registry + # @return [Symbol] + def self.event_id + :step_activated + end + + def initialize(test_step, step_match) + @test_step = test_step + @step_match = step_match + super() + end end end end diff --git a/lib/cucumber/events/step_definition_registered.rb b/lib/cucumber/events/step_definition_registered.rb index 4770b889c..0b9b27022 100644 --- a/lib/cucumber/events/step_definition_registered.rb +++ b/lib/cucumber/events/step_definition_registered.rb @@ -5,11 +5,21 @@ module Cucumber module Events # Event fired after each step definition has been registered - class StepDefinitionRegistered < Core::Event.new(:step_definition) + class StepDefinitionRegistered < BaseEventNew # The step definition that was just registered. - # - # @return [RbSupport::RbStepDefinition] + # @return [RbSupport::RbStepDefinition] attr_reader :step_definition + + # The underscored name of the class to be used as the key in an event registry + # @return [Symbol] + def self.event_id + :step_definition_registered + end + + def initialize(step_definition) + @step_definition = step_definition + super() + end end end end diff --git a/lib/cucumber/events/test_case_created.rb b/lib/cucumber/events/test_case_created.rb index c23e2a9d6..4f5b0bb88 100644 --- a/lib/cucumber/events/test_case_created.rb +++ b/lib/cucumber/events/test_case_created.rb @@ -5,8 +5,20 @@ module Cucumber module Events # Event fired when a Test::Case is created from a Pickle - class TestCaseCreated < Core::Event.new(:test_case, :pickle) + class TestCaseCreated < BaseEventNew attr_reader :test_case, :pickle + + # The underscored name of the class to be used as the key in an event registry + # @return [Symbol] + def self.event_id + :test_case_created + end + + def initialize(test_case, pickle) + @test_case = test_case + @pickle = pickle + super() + end end end end From 71c4e9ea02613a54578a1abbfe7c2d1741efafc4 Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Fri, 24 Apr 2026 00:30:46 +0100 Subject: [PATCH 09/15] Fix load order issues --- lib/cucumber/glue/registry_and_more.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/cucumber/glue/registry_and_more.rb b/lib/cucumber/glue/registry_and_more.rb index f042c027a..3b9b58ed4 100644 --- a/lib/cucumber/glue/registry_and_more.rb +++ b/lib/cucumber/glue/registry_and_more.rb @@ -13,6 +13,7 @@ require 'cucumber/gherkin/i18n' require 'multi_test' require 'cucumber/step_match' +require 'cucumber/events/base_event_new' require 'cucumber/events/step_definition_registered' module Cucumber From 7da4ff56534c7a7fb7070b2a0591dc3d859465c9 Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Fri, 24 Apr 2026 00:35:46 +0100 Subject: [PATCH 10/15] Fix up all refs to attributes in legacy formatters --- lib/cucumber/formatter/fail_fast.rb | 7 +++---- lib/cucumber/formatter/json.rb | 6 ++++-- lib/cucumber/formatter/junit.rb | 10 ++++------ lib/cucumber/formatter/pretty.rb | 3 +-- lib/cucumber/formatter/usage.rb | 3 +-- 5 files changed, 13 insertions(+), 16 deletions(-) diff --git a/lib/cucumber/formatter/fail_fast.rb b/lib/cucumber/formatter/fail_fast.rb index 3ebac8acf..60ba4f08d 100644 --- a/lib/cucumber/formatter/fail_fast.rb +++ b/lib/cucumber/formatter/fail_fast.rb @@ -9,11 +9,10 @@ class FailFast def initialize(configuration) @previous_test_case = nil configuration.on_event :test_case_finished do |event| - test_case, result = *event.attributes - if test_case != @previous_test_case + if event.test_case != @previous_test_case @previous_test_case = event.test_case - Cucumber.wants_to_quit = true unless result.ok?(strict: configuration.strict) - elsif result.passed? + Cucumber.wants_to_quit = true unless event.result.ok?(strict: configuration.strict) + elsif event.result.passed? Cucumber.wants_to_quit = false end end diff --git a/lib/cucumber/formatter/json.rb b/lib/cucumber/formatter/json.rb index 8fc8471a4..731ed8ff1 100644 --- a/lib/cucumber/formatter/json.rb +++ b/lib/cucumber/formatter/json.rb @@ -65,7 +65,8 @@ def on_test_step_started(event) end def on_test_step_finished(event) - test_step, result = *event.attributes + test_step = event.test_step + result = event.result result = result.with_filtered_backtrace(Cucumber::Formatter::BacktraceFilter) return if internal_hook?(test_step) @@ -76,7 +77,8 @@ def on_test_step_finished(event) def on_test_case_finished(event) feature_elements << @test_case_hash if @in_background - _test_case, result = *event.attributes + _test_case = event.test_case + result = event.result result = result.with_filtered_backtrace(Cucumber::Formatter::BacktraceFilter) add_failed_around_hook(result) if result.failed? && !@any_step_failed end diff --git a/lib/cucumber/formatter/junit.rb b/lib/cucumber/formatter/junit.rb index f4f9dba47..9cb07ff57 100644 --- a/lib/cucumber/formatter/junit.rb +++ b/lib/cucumber/formatter/junit.rb @@ -51,19 +51,17 @@ def on_test_case_started(event) end def on_test_step_finished(event) - test_step, result = *event.attributes return if @failing_test_step - @failing_test_step = test_step unless result.ok?(strict: @config.strict) + @failing_test_step = event.test_step unless event.result.ok?(strict: @config.strict) end def on_test_case_finished(event) - test_case, result = *event.attributes - result = result.with_filtered_backtrace(Cucumber::Formatter::BacktraceFilter) - test_case_name = NameBuilder.new(test_case, @ast_lookup) + result = event.result.with_filtered_backtrace(Cucumber::Formatter::BacktraceFilter) + test_case_name = NameBuilder.new(event.test_case, @ast_lookup) scenario = test_case_name.scenario_name scenario_designation = "#{scenario}#{test_case_name.name_suffix}" - output = create_output_string(test_case, scenario, result, test_case_name.row_name) + output = create_output_string(event.test_case, scenario, result, test_case_name.row_name) build_testcase(result, scenario_designation, output) Interceptor::Pipe.unwrap! :stdout diff --git a/lib/cucumber/formatter/pretty.rb b/lib/cucumber/formatter/pretty.rb index 97ba8d796..a660d05c2 100644 --- a/lib/cucumber/formatter/pretty.rb +++ b/lib/cucumber/formatter/pretty.rb @@ -73,8 +73,7 @@ def on_gherkin_source_read(event) end def on_step_activated(event) - test_step, step_match = *event.attributes - @step_matches[test_step.to_s] = step_match + @step_matches[event.test_step.to_s] = event.step_match end def on_test_case_started(event) diff --git a/lib/cucumber/formatter/usage.rb b/lib/cucumber/formatter/usage.rb index 6852e0791..f17680ff4 100644 --- a/lib/cucumber/formatter/usage.rb +++ b/lib/cucumber/formatter/usage.rb @@ -32,8 +32,7 @@ def initialize(config) @total_duration = 0 @matches = {} config.on_event :step_activated do |event| - test_step, step_match = *event.attributes - @matches[test_step.to_s] = step_match + @matches[event.test_step.to_s] = event.step_match end config.on_event :step_definition_registered, &method(:on_step_definition_registered) end From 49bdf08c443c3cf5df71beb6e92cd91300f489d0 Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Fri, 24 Apr 2026 00:40:05 +0100 Subject: [PATCH 11/15] Copilot refactor --- lib/cucumber/events/base_event_new.rb | 4 ++++ lib/cucumber/events/gherkin_source_parsed.rb | 6 ++---- lib/cucumber/events/hook_test_step_created.rb | 2 +- .../events/step_definition_registered.rb | 2 +- lib/cucumber/events/test_case_started.rb | 17 +++++++++++++---- lib/cucumber/events/test_run_started.rb | 13 +++++++++++-- lib/cucumber/events/test_step_created.rb | 14 ++++++++++++-- lib/cucumber/events/test_step_finished.rb | 14 ++++++++++++-- lib/cucumber/events/test_step_started.rb | 13 +++++++++++-- 9 files changed, 67 insertions(+), 18 deletions(-) diff --git a/lib/cucumber/events/base_event_new.rb b/lib/cucumber/events/base_event_new.rb index f2e0d2ee6..b1cb266d1 100644 --- a/lib/cucumber/events/base_event_new.rb +++ b/lib/cucumber/events/base_event_new.rb @@ -12,6 +12,10 @@ def to_h instance_variables.to_h { |variable_name| [variable_name[1..].to_sym, instance_variable_get(variable_name)] } end + def to_hash + to_h + end + def event_id self.class.event_id end diff --git a/lib/cucumber/events/gherkin_source_parsed.rb b/lib/cucumber/events/gherkin_source_parsed.rb index 276a2586b..fc143d619 100644 --- a/lib/cucumber/events/gherkin_source_parsed.rb +++ b/lib/cucumber/events/gherkin_source_parsed.rb @@ -1,6 +1,4 @@ -# frozen_string_literal: true - -require 'cucumber/core/events' +# frozen_string_literal: require_relative 'base_event_new' module Cucumber module Events @@ -10,7 +8,7 @@ class GherkinSourceParsed < BaseEventNew attr_reader :gherkin_document # The underscored name of the class to be used as the key in an event registry - # @return [Symbol] + # @return [Symb def self.event_id :gherkin_source_parsed end diff --git a/lib/cucumber/events/hook_test_step_created.rb b/lib/cucumber/events/hook_test_step_created.rb index 9a1678ed1..6e63e5190 100644 --- a/lib/cucumber/events/hook_test_step_created.rb +++ b/lib/cucumber/events/hook_test_step_created.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'cucumber/core/events' +require_relative 'base_event_new' module Cucumber module Events diff --git a/lib/cucumber/events/step_definition_registered.rb b/lib/cucumber/events/step_definition_registered.rb index 0b9b27022..59e2f2614 100644 --- a/lib/cucumber/events/step_definition_registered.rb +++ b/lib/cucumber/events/step_definition_registered.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'cucumber/core/events' +require_relative 'base_event_new' module Cucumber module Events diff --git a/lib/cucumber/events/test_case_started.rb b/lib/cucumber/events/test_case_started.rb index 2f131f25d..b8f05ef83 100644 --- a/lib/cucumber/events/test_case_started.rb +++ b/lib/cucumber/events/test_case_started.rb @@ -1,13 +1,22 @@ # frozen_string_literal: true -require 'cucumber/core/events' +require_relative 'base_event_new' module Cucumber module Events # Signals that a {Cucumber::Core::Test::Case} is about to be executed - class TestCaseStarted < Core::Events::TestCaseStarted - # # @return [Cucumber::Core::Test::Case] the test case to be executed - # attr_reader :test_case + class TestCaseStarted < BaseEventNew + # @return [Cucumber::Core::Test::Case] the test case to be executed + attr_reader :test_case + + def self.event_id + :test_case_started + end + + def initialize(test_case) + @test_case = test_case + super() + end end end end diff --git a/lib/cucumber/events/test_run_started.rb b/lib/cucumber/events/test_run_started.rb index 638cf7ec2..5bee7a553 100644 --- a/lib/cucumber/events/test_run_started.rb +++ b/lib/cucumber/events/test_run_started.rb @@ -1,14 +1,23 @@ # frozen_string_literal: true -require 'cucumber/core/events' +require_relative 'base_event_new' module Cucumber module Events # Event fired once all test cases have been filtered before # the first one is executed. - class TestRunStarted < Core::Event.new(:test_cases) + class TestRunStarted < BaseEventNew # @return [Array] the test cases to be executed attr_reader :test_cases + + def self.event_id + :test_run_started + end + + def initialize(test_cases) + @test_cases = test_cases + super() + end end end end diff --git a/lib/cucumber/events/test_step_created.rb b/lib/cucumber/events/test_step_created.rb index 577d8f831..36e51ef58 100644 --- a/lib/cucumber/events/test_step_created.rb +++ b/lib/cucumber/events/test_step_created.rb @@ -1,12 +1,22 @@ # frozen_string_literal: true -require 'cucumber/core/events' +require_relative 'base_event_new' module Cucumber module Events # Event fired when a TestStep is created from a PickleStep - class TestStepCreated < Core::Event.new(:test_step, :pickle_step) + class TestStepCreated < BaseEventNew attr_reader :test_step, :pickle_step + + def self.event_id + :test_step_created + end + + def initialize(test_step, pickle_step) + @test_step = test_step + @pickle_step = pickle_step + super() + end end end end diff --git a/lib/cucumber/events/test_step_finished.rb b/lib/cucumber/events/test_step_finished.rb index bf7319955..33cec63ba 100644 --- a/lib/cucumber/events/test_step_finished.rb +++ b/lib/cucumber/events/test_step_finished.rb @@ -1,16 +1,26 @@ # frozen_string_literal: true -require 'cucumber/core/events' +require_relative 'base_event_new' module Cucumber module Events # Signals that a {Cucumber::Core::Test::Step} has finished executing - class TestStepFinished < Core::Events::TestStepFinished + class TestStepFinished < BaseEventNew # @return [Cucumber::Core::Test::Step] the test step that was executed attr_reader :test_step # @return [Cucumber::Core::Test::Result] the result of running the {Cucumber::Core::Test::Step} attr_reader :result + + def self.event_id + :test_step_finished + end + + def initialize(test_step, result) + @test_step = test_step + @result = result + super() + end end end end diff --git a/lib/cucumber/events/test_step_started.rb b/lib/cucumber/events/test_step_started.rb index 9758694a6..298e317e4 100644 --- a/lib/cucumber/events/test_step_started.rb +++ b/lib/cucumber/events/test_step_started.rb @@ -1,13 +1,22 @@ # frozen_string_literal: true -require 'cucumber/core/events' +require_relative 'base_event_new' module Cucumber module Events # Signals that a {Cucumber::Core::Test::Step} is about to be executed - class TestStepStarted < Core::Events::TestStepStarted + class TestStepStarted < BaseEventNew # @return [Cucumber::Core::Test::Step] the test step to be executed attr_reader :test_step + + def self.event_id + :test_step_started + end + + def initialize(test_step) + @test_step = test_step + super() + end end end end From d6ddb26de6fddd4099186051d3d721da614d68d0 Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Fri, 24 Apr 2026 00:44:10 +0100 Subject: [PATCH 12/15] More tidy up of some events --- lib/cucumber/events/gherkin_source_parsed.rb | 4 +++- lib/cucumber/events/gherkin_source_read.rb | 2 -- lib/cucumber/events/step_activated.rb | 2 -- lib/cucumber/events/test_case_created.rb | 2 -- lib/cucumber/events/test_case_finished.rb | 18 ++++++++++++++---- lib/cucumber/events/test_case_ready.rb | 16 ++++++++++++---- lib/cucumber/events/test_run_finished.rb | 13 ++++++++++--- 7 files changed, 39 insertions(+), 18 deletions(-) diff --git a/lib/cucumber/events/gherkin_source_parsed.rb b/lib/cucumber/events/gherkin_source_parsed.rb index fc143d619..62cac0b5a 100644 --- a/lib/cucumber/events/gherkin_source_parsed.rb +++ b/lib/cucumber/events/gherkin_source_parsed.rb @@ -1,4 +1,6 @@ -# frozen_string_literal: require_relative 'base_event_new' +# frozen_string_literal: true + +require_relative 'base_event_new' module Cucumber module Events diff --git a/lib/cucumber/events/gherkin_source_read.rb b/lib/cucumber/events/gherkin_source_read.rb index 4d66498c6..92400cf11 100644 --- a/lib/cucumber/events/gherkin_source_read.rb +++ b/lib/cucumber/events/gherkin_source_read.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -require 'cucumber/core/events' - module Cucumber module Events # Fired after we've read in the contents of a feature file diff --git a/lib/cucumber/events/step_activated.rb b/lib/cucumber/events/step_activated.rb index af38122de..a253d1590 100644 --- a/lib/cucumber/events/step_activated.rb +++ b/lib/cucumber/events/step_activated.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -require 'cucumber/core/events' - module Cucumber module Events # Event fired when a step is activated diff --git a/lib/cucumber/events/test_case_created.rb b/lib/cucumber/events/test_case_created.rb index 4f5b0bb88..5985f6092 100644 --- a/lib/cucumber/events/test_case_created.rb +++ b/lib/cucumber/events/test_case_created.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -require 'cucumber/core/events' - module Cucumber module Events # Event fired when a Test::Case is created from a Pickle diff --git a/lib/cucumber/events/test_case_finished.rb b/lib/cucumber/events/test_case_finished.rb index 0083203f0..48284be6b 100644 --- a/lib/cucumber/events/test_case_finished.rb +++ b/lib/cucumber/events/test_case_finished.rb @@ -1,16 +1,26 @@ # frozen_string_literal: true -require 'cucumber/core/events' - module Cucumber module Events - # Signals that a {Cucumber::Core::Test::Case} has finished executing - class TestCaseFinished < Core::Events::TestCaseFinished + # Event fired when a Test::Case is created from a Pickle + class TestCaseFinished < BaseEventNew # @return [Cucumber::Core::Test::Case] that was executed attr_reader :test_case # @return [Cucumber::Core::Test::Result] the result of running the {Cucumber::Core::Test::Case} attr_reader :result + + # The underscored name of the class to be used as the key in an event registry + # @return [Symbol] + def self.event_id + :test_case_finished + end + + def initialize(test_case, result) + @test_case = test_case + @result = result + super() + end end end end diff --git a/lib/cucumber/events/test_case_ready.rb b/lib/cucumber/events/test_case_ready.rb index 3ffa86fb6..683634b22 100644 --- a/lib/cucumber/events/test_case_ready.rb +++ b/lib/cucumber/events/test_case_ready.rb @@ -1,12 +1,20 @@ # frozen_string_literal: true -require 'cucumber/core/events' - module Cucumber module Events - # Event fired when a Test::Case is ready to be ran (matching has been done, hooks added etc) - class TestCaseReady < Core::Event.new(:test_case) + class TestCaseReady < BaseEventNew attr_reader :test_case + + # The underscored name of the class to be used as the key in an event registry + # @return [Symbol] + def self.event_id + :test_case_ready + end + + def initialize(test_case) + @test_case = test_case + super() + end end end end diff --git a/lib/cucumber/events/test_run_finished.rb b/lib/cucumber/events/test_run_finished.rb index 67c607e4c..45c44d49e 100644 --- a/lib/cucumber/events/test_run_finished.rb +++ b/lib/cucumber/events/test_run_finished.rb @@ -1,12 +1,19 @@ # frozen_string_literal: true -require 'cucumber/core/events' - module Cucumber module Events # Event fired after all test cases have finished executing - class TestRunFinished < Core::Event.new(:success) + class TestRunFinished < BaseEventNew attr_reader :success + + def self.event_id + :test_run_finished + end + + def initialize(success) + @success = success + super() + end end end end From e5d455c5e68d2609077720832bb0191e63beddc1 Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Fri, 24 Apr 2026 18:12:22 +0100 Subject: [PATCH 13/15] Default success to `nil` in line with previous implementation --- lib/cucumber/events/base_event_new.rb | 4 ---- lib/cucumber/events/test_run_finished.rb | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/cucumber/events/base_event_new.rb b/lib/cucumber/events/base_event_new.rb index b1cb266d1..f2e0d2ee6 100644 --- a/lib/cucumber/events/base_event_new.rb +++ b/lib/cucumber/events/base_event_new.rb @@ -12,10 +12,6 @@ def to_h instance_variables.to_h { |variable_name| [variable_name[1..].to_sym, instance_variable_get(variable_name)] } end - def to_hash - to_h - end - def event_id self.class.event_id end diff --git a/lib/cucumber/events/test_run_finished.rb b/lib/cucumber/events/test_run_finished.rb index 45c44d49e..d2e082eb9 100644 --- a/lib/cucumber/events/test_run_finished.rb +++ b/lib/cucumber/events/test_run_finished.rb @@ -10,7 +10,7 @@ def self.event_id :test_run_finished end - def initialize(success) + def initialize(success = nil) @success = success super() end From 4a207dcade1f3882017373229d9b5fcb2104b085 Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Fri, 24 Apr 2026 18:16:01 +0100 Subject: [PATCH 14/15] Switch over name to simpler format and add a little more docs --- lib/cucumber/events/base.rb | 24 +++++++++++++++++++ lib/cucumber/events/base_event_new.rb | 20 ---------------- lib/cucumber/events/envelope.rb | 4 ++-- lib/cucumber/events/gherkin_source_parsed.rb | 4 ++-- lib/cucumber/events/gherkin_source_read.rb | 2 +- lib/cucumber/events/hook_test_step_created.rb | 4 ++-- lib/cucumber/events/step_activated.rb | 2 +- .../events/step_definition_registered.rb | 4 ++-- lib/cucumber/events/test_case_created.rb | 2 +- lib/cucumber/events/test_case_finished.rb | 2 +- lib/cucumber/events/test_case_ready.rb | 2 +- lib/cucumber/events/test_case_started.rb | 4 ++-- lib/cucumber/events/test_run_finished.rb | 2 +- lib/cucumber/events/test_run_started.rb | 4 ++-- lib/cucumber/events/test_step_created.rb | 4 ++-- lib/cucumber/events/test_step_finished.rb | 4 ++-- lib/cucumber/events/test_step_started.rb | 4 ++-- lib/cucumber/glue/registry_and_more.rb | 2 +- 18 files changed, 49 insertions(+), 45 deletions(-) create mode 100644 lib/cucumber/events/base.rb delete mode 100644 lib/cucumber/events/base_event_new.rb diff --git a/lib/cucumber/events/base.rb b/lib/cucumber/events/base.rb new file mode 100644 index 000000000..3593c7c58 --- /dev/null +++ b/lib/cucumber/events/base.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +module Cucumber + module Events + # An archetype of what each Cucumber Event defined in cucumber-ruby must adhere to + class Base + # The "key" name of the class to be used as the key in the event registry (Underscored name symbolized) + # @return [Symbol] + def self.event_id + raise 'Must be implemented in subclass' + end + + # The properties of each event. Stored in iVar named format - where the key is the name of the iVar + # @return [Hash] + def to_h + instance_variables.to_h { |variable_name| [variable_name[1..].to_sym, instance_variable_get(variable_name)] } + end + + def event_id + self.class.event_id + end + end + end +end diff --git a/lib/cucumber/events/base_event_new.rb b/lib/cucumber/events/base_event_new.rb deleted file mode 100644 index f2e0d2ee6..000000000 --- a/lib/cucumber/events/base_event_new.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -module Cucumber - module Events - class BaseEventNew - # @return [Symbol] the underscored name of the class to be used as the key in an event registry - def self.event_id - raise 'Must be implemented in subclass' - end - - def to_h - instance_variables.to_h { |variable_name| [variable_name[1..].to_sym, instance_variable_get(variable_name)] } - end - - def event_id - self.class.event_id - end - end - end -end diff --git a/lib/cucumber/events/envelope.rb b/lib/cucumber/events/envelope.rb index 03e40475a..fe98ccf0f 100644 --- a/lib/cucumber/events/envelope.rb +++ b/lib/cucumber/events/envelope.rb @@ -1,10 +1,10 @@ # frozen_string_literal: true -require_relative 'base_event_new' +require_relative 'base' module Cucumber module Events - class Envelope < BaseEventNew + class Envelope < Base attr_reader :envelope # The underscored name of the class to be used as the key in an event registry diff --git a/lib/cucumber/events/gherkin_source_parsed.rb b/lib/cucumber/events/gherkin_source_parsed.rb index 62cac0b5a..125190d83 100644 --- a/lib/cucumber/events/gherkin_source_parsed.rb +++ b/lib/cucumber/events/gherkin_source_parsed.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -require_relative 'base_event_new' +require_relative 'base' module Cucumber module Events # Fired after we've parsed the contents of a feature file - class GherkinSourceParsed < BaseEventNew + class GherkinSourceParsed < Base # # The Gherkin Ast attr_reader :gherkin_document diff --git a/lib/cucumber/events/gherkin_source_read.rb b/lib/cucumber/events/gherkin_source_read.rb index 92400cf11..8df4a69d6 100644 --- a/lib/cucumber/events/gherkin_source_read.rb +++ b/lib/cucumber/events/gherkin_source_read.rb @@ -3,7 +3,7 @@ module Cucumber module Events # Fired after we've read in the contents of a feature file - class GherkinSourceRead < BaseEventNew + class GherkinSourceRead < Base # The path to the file attr_reader :path diff --git a/lib/cucumber/events/hook_test_step_created.rb b/lib/cucumber/events/hook_test_step_created.rb index 6e63e5190..5814afa94 100644 --- a/lib/cucumber/events/hook_test_step_created.rb +++ b/lib/cucumber/events/hook_test_step_created.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -require_relative 'base_event_new' +require_relative 'base' module Cucumber module Events # Event fired when a step is created from a hook - class HookTestStepCreated < BaseEventNew + class HookTestStepCreated < Base attr_reader :test_step, :hook # The underscored name of the class to be used as the key in an event registry diff --git a/lib/cucumber/events/step_activated.rb b/lib/cucumber/events/step_activated.rb index a253d1590..6f2fc1ba9 100644 --- a/lib/cucumber/events/step_activated.rb +++ b/lib/cucumber/events/step_activated.rb @@ -3,7 +3,7 @@ module Cucumber module Events # Event fired when a step is activated - class StepActivated < BaseEventNew + class StepActivated < Base # The test step that was matched. # @return [Cucumber::Core::Test::Step] attr_reader :test_step diff --git a/lib/cucumber/events/step_definition_registered.rb b/lib/cucumber/events/step_definition_registered.rb index 59e2f2614..31746394d 100644 --- a/lib/cucumber/events/step_definition_registered.rb +++ b/lib/cucumber/events/step_definition_registered.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -require_relative 'base_event_new' +require_relative 'base' module Cucumber module Events # Event fired after each step definition has been registered - class StepDefinitionRegistered < BaseEventNew + class StepDefinitionRegistered < Base # The step definition that was just registered. # @return [RbSupport::RbStepDefinition] attr_reader :step_definition diff --git a/lib/cucumber/events/test_case_created.rb b/lib/cucumber/events/test_case_created.rb index 5985f6092..f93717e38 100644 --- a/lib/cucumber/events/test_case_created.rb +++ b/lib/cucumber/events/test_case_created.rb @@ -3,7 +3,7 @@ module Cucumber module Events # Event fired when a Test::Case is created from a Pickle - class TestCaseCreated < BaseEventNew + class TestCaseCreated < Base attr_reader :test_case, :pickle # The underscored name of the class to be used as the key in an event registry diff --git a/lib/cucumber/events/test_case_finished.rb b/lib/cucumber/events/test_case_finished.rb index 48284be6b..1c5566e8c 100644 --- a/lib/cucumber/events/test_case_finished.rb +++ b/lib/cucumber/events/test_case_finished.rb @@ -3,7 +3,7 @@ module Cucumber module Events # Event fired when a Test::Case is created from a Pickle - class TestCaseFinished < BaseEventNew + class TestCaseFinished < Base # @return [Cucumber::Core::Test::Case] that was executed attr_reader :test_case diff --git a/lib/cucumber/events/test_case_ready.rb b/lib/cucumber/events/test_case_ready.rb index 683634b22..71d804ecb 100644 --- a/lib/cucumber/events/test_case_ready.rb +++ b/lib/cucumber/events/test_case_ready.rb @@ -2,7 +2,7 @@ module Cucumber module Events - class TestCaseReady < BaseEventNew + class TestCaseReady < Base attr_reader :test_case # The underscored name of the class to be used as the key in an event registry diff --git a/lib/cucumber/events/test_case_started.rb b/lib/cucumber/events/test_case_started.rb index b8f05ef83..d19b56fd8 100644 --- a/lib/cucumber/events/test_case_started.rb +++ b/lib/cucumber/events/test_case_started.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -require_relative 'base_event_new' +require_relative 'base' module Cucumber module Events # Signals that a {Cucumber::Core::Test::Case} is about to be executed - class TestCaseStarted < BaseEventNew + class TestCaseStarted < Base # @return [Cucumber::Core::Test::Case] the test case to be executed attr_reader :test_case diff --git a/lib/cucumber/events/test_run_finished.rb b/lib/cucumber/events/test_run_finished.rb index d2e082eb9..7db6ffbb8 100644 --- a/lib/cucumber/events/test_run_finished.rb +++ b/lib/cucumber/events/test_run_finished.rb @@ -3,7 +3,7 @@ module Cucumber module Events # Event fired after all test cases have finished executing - class TestRunFinished < BaseEventNew + class TestRunFinished < Base attr_reader :success def self.event_id diff --git a/lib/cucumber/events/test_run_started.rb b/lib/cucumber/events/test_run_started.rb index 5bee7a553..03a94e19e 100644 --- a/lib/cucumber/events/test_run_started.rb +++ b/lib/cucumber/events/test_run_started.rb @@ -1,12 +1,12 @@ # frozen_string_literal: true -require_relative 'base_event_new' +require_relative 'base' module Cucumber module Events # Event fired once all test cases have been filtered before # the first one is executed. - class TestRunStarted < BaseEventNew + class TestRunStarted < Base # @return [Array] the test cases to be executed attr_reader :test_cases diff --git a/lib/cucumber/events/test_step_created.rb b/lib/cucumber/events/test_step_created.rb index 36e51ef58..0d15af4dc 100644 --- a/lib/cucumber/events/test_step_created.rb +++ b/lib/cucumber/events/test_step_created.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -require_relative 'base_event_new' +require_relative 'base' module Cucumber module Events # Event fired when a TestStep is created from a PickleStep - class TestStepCreated < BaseEventNew + class TestStepCreated < Base attr_reader :test_step, :pickle_step def self.event_id diff --git a/lib/cucumber/events/test_step_finished.rb b/lib/cucumber/events/test_step_finished.rb index 33cec63ba..7c8dc8478 100644 --- a/lib/cucumber/events/test_step_finished.rb +++ b/lib/cucumber/events/test_step_finished.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -require_relative 'base_event_new' +require_relative 'base' module Cucumber module Events # Signals that a {Cucumber::Core::Test::Step} has finished executing - class TestStepFinished < BaseEventNew + class TestStepFinished < Base # @return [Cucumber::Core::Test::Step] the test step that was executed attr_reader :test_step diff --git a/lib/cucumber/events/test_step_started.rb b/lib/cucumber/events/test_step_started.rb index 298e317e4..ca0b22ce4 100644 --- a/lib/cucumber/events/test_step_started.rb +++ b/lib/cucumber/events/test_step_started.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -require_relative 'base_event_new' +require_relative 'base' module Cucumber module Events # Signals that a {Cucumber::Core::Test::Step} is about to be executed - class TestStepStarted < BaseEventNew + class TestStepStarted < Base # @return [Cucumber::Core::Test::Step] the test step to be executed attr_reader :test_step diff --git a/lib/cucumber/glue/registry_and_more.rb b/lib/cucumber/glue/registry_and_more.rb index 3b9b58ed4..d678735d4 100644 --- a/lib/cucumber/glue/registry_and_more.rb +++ b/lib/cucumber/glue/registry_and_more.rb @@ -13,7 +13,7 @@ require 'cucumber/gherkin/i18n' require 'multi_test' require 'cucumber/step_match' -require 'cucumber/events/base_event_new' +require 'cucumber/events/base' require 'cucumber/events/step_definition_registered' module Cucumber From def20061cc72b821ee2d5af1b53c5a71d227c249 Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Fri, 24 Apr 2026 18:18:39 +0100 Subject: [PATCH 15/15] Add final missing conversions to new event type format --- lib/cucumber/events/test_run_hook_finished.rb | 14 +++++++++++--- lib/cucumber/events/test_run_hook_started.rb | 11 ++++++++++- lib/cucumber/events/undefined_parameter_type.rb | 14 +++++++++++--- 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/lib/cucumber/events/test_run_hook_finished.rb b/lib/cucumber/events/test_run_hook_finished.rb index 31efc6317..615f5161c 100644 --- a/lib/cucumber/events/test_run_hook_finished.rb +++ b/lib/cucumber/events/test_run_hook_finished.rb @@ -1,11 +1,19 @@ # frozen_string_literal: true -require 'cucumber/core/events' - module Cucumber module Events - class TestRunHookFinished < Core::Event.new(:hook, :test_result) + class TestRunHookFinished < Base attr_reader :hook, :test_result + + def self.event_id + :test_run_hook_finished + end + + def initialize(hook, test_result) + @hook = hook + @test_result = test_result + super() + end end end end diff --git a/lib/cucumber/events/test_run_hook_started.rb b/lib/cucumber/events/test_run_hook_started.rb index 43577ffad..7847d06d5 100644 --- a/lib/cucumber/events/test_run_hook_started.rb +++ b/lib/cucumber/events/test_run_hook_started.rb @@ -4,8 +4,17 @@ module Cucumber module Events - class TestRunHookStarted < Core::Event.new(:hook) + class TestRunHookStarted < Base attr_reader :hook + + def self.event_id + :test_run_hook_started + end + + def initialize(hook) + @hook = hook + super() + end end end end diff --git a/lib/cucumber/events/undefined_parameter_type.rb b/lib/cucumber/events/undefined_parameter_type.rb index bb52281a4..b48d46324 100644 --- a/lib/cucumber/events/undefined_parameter_type.rb +++ b/lib/cucumber/events/undefined_parameter_type.rb @@ -1,11 +1,19 @@ # frozen_string_literal: true -require 'cucumber/core/events' - module Cucumber module Events - class UndefinedParameterType < Core::Event.new(:type_name, :expression) + class UndefinedParameterType < Base attr_reader :type_name, :expression + + def self.event_id + :undefined_parameter_type + end + + def initialize(type_name, expression) + @type_name = type_name + @expression = expression + super() + end end end end