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) 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