diff --git a/CHANGELOG.md b/CHANGELOG.md index 70e0c7e26b..805d3a4e13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,7 +25,10 @@ Please visit [cucumber/CONTRIBUTING.md](https://github.com/cucumber/cucumber/blo logic and some old rspec helper files) - Removed handling of a Ruby 2.1 system error ([luke-hill](https://github.com/luke-hill)) - Removed support for Ruby 3.1 and 3.2 (Minimum ruby is now 3.3) ([luke-hill](https://github.com/luke-hill)) - + +### Fixed +- Updated the `html-formatter` to access message stream correctly ([#1899](https://github.com/cucumber/cucumber-ruby/pull/1899)) [brasmusson](https://github.com/brasmusson) + ## [11.1.1] - 2026-06-25 ### Changed - Change to use events to pass the data from "log" and "attach" calls from the step definitions to the formatters. With this the last part of the ancient (pre event) formatter inteface has been removed. ([#1881](https://github.com/cucumber/cucumber-ruby/pull/1881) [brasmusson](https://github.com/brasmusson)) diff --git a/features/docs/formatters/html.feature b/features/docs/formatters/html.feature index aa4f4fe9a6..16308966cf 100644 --- a/features/docs/formatters/html.feature +++ b/features/docs/formatters/html.feature @@ -19,3 +19,7 @@ Feature: html formatter When I run `cucumber features/my_feature.feature --format html` Then it should fail And output should be html with title "Cucumber" + And the output should contain: + """ + Scenario Outline: a scenario + """ diff --git a/lib/cucumber/formatter/html.rb b/lib/cucumber/formatter/html.rb index 67637518d0..95a87d9d73 100644 --- a/lib/cucumber/formatter/html.rb +++ b/lib/cucumber/formatter/html.rb @@ -2,20 +2,22 @@ require 'cucumber/html_formatter' -require_relative 'message_builder' +require_relative 'io' module Cucumber module Formatter - class HTML < MessageBuilder + class HTML + include Io + def initialize(config) + @config = config @io = ensure_io(config.out_stream, config.error_stream) @html_formatter = Cucumber::HTMLFormatter::Formatter.new(@io) @html_formatter.write_pre_message - super(config) + config.on_event :envelope, &method(:on_envelope) end def on_envelope(event) - super(event) envelope = event.envelope @html_formatter.write_message(envelope) # TODO: Move this conditional logic into the HTML formatter proper diff --git a/lib/cucumber/runtime.rb b/lib/cucumber/runtime.rb index fd5f1e4233..9cddf73a69 100644 --- a/lib/cucumber/runtime.rb +++ b/lib/cucumber/runtime.rb @@ -172,14 +172,13 @@ def set_encoding require 'cucumber/core/report/summary' def create_formatters - # Define all formatters which are specified via cli options - formatters - # Define the MessageBuilder formatter - Required until all messages are generated at the source - # Skip when a user formatter already inherits from MessageBuilder (e.g. HTML) to avoid sending every event twice. - message_builder unless formatters.any? { |f| f.is_a?(Formatter::MessageBuilder) } + # Define the MessageBuilder - Required until all messages are generated at the source + message_builder # `summary_report` and `global_hooks_summary_report` are used to determine the exit code summary_report global_hooks_summary_report + # Define all formatters which are specified via cli options + formatters fail_fast_report if @configuration.fail_fast? publish_banner_printer unless @configuration.publish_quiet? end