From 5e002511b66da9f4624759b37ffda493fca9ed2a Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Fri, 22 May 2026 16:16:38 +0100 Subject: [PATCH 1/2] Add envelope generation at source for gherkin_source_read event --- lib/cucumber/runtime.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/cucumber/runtime.rb b/lib/cucumber/runtime.rb index 3315fd171..36164aeec 100644 --- a/lib/cucumber/runtime.rb +++ b/lib/cucumber/runtime.rb @@ -136,6 +136,19 @@ def features @features ||= feature_files.map do |path| source = NormalisedEncodingFile.read(path) @configuration.notify :gherkin_source_read, path, source + + # TODO: Move this into `Cucumber::Core::Gherkin::Document#to_envelope` + to_envelope = + Cucumber::Messages::Envelope.new( + source: Cucumber::Messages::Source.new( + uri: path, + data: source, + media_type: 'text/x.cucumber.gherkin+plain' + ) + ) + + @configuration.notify :envelope, to_envelope + Cucumber::Core::Gherkin::Document.new(path, source) end end From d809fc2fbd93c090a5b073c433409eb9e2a54bea Mon Sep 17 00:00:00 2001 From: Luke Hill Date: Fri, 22 May 2026 16:20:16 +0100 Subject: [PATCH 2/2] Do not double fire events --- lib/cucumber/formatter/message_builder.rb | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/lib/cucumber/formatter/message_builder.rb b/lib/cucumber/formatter/message_builder.rb index 86a0e9204..9259ea907 100644 --- a/lib/cucumber/formatter/message_builder.rb +++ b/lib/cucumber/formatter/message_builder.rb @@ -87,16 +87,10 @@ def on_gherkin_source_parsed(_event) # TODO: Handle GherkinSourceParsed end - def on_gherkin_source_read(event) - message = Cucumber::Messages::Envelope.new( - source: Cucumber::Messages::Source.new( - uri: event.path, - data: event.body, - media_type: 'text/x.cucumber.gherkin+plain' - ) - ) - - output_envelope(message) + def on_gherkin_source_read(_event) + :no_op + # This is now emitted at the required source (Single event listener - cucumber/runtime.rb#features) + # It does not need to be emitted here as well end def on_hook_test_step_created(event)