Skip to content

Use events also when step definitions use "attach" and "log"#1881

Merged
brasmusson merged 4 commits into
mainfrom
feature/attach-event
Jun 4, 2026
Merged

Use events also when step definitions use "attach" and "log"#1881
brasmusson merged 4 commits into
mainfrom
feature/attach-event

Conversation

@brasmusson

@brasmusson brasmusson commented May 31, 2026

Copy link
Copy Markdown
Contributor

Description

Remove the ancient procedure call interface from formatters completely

Until now the data from "attach" and "log" calls from step definitions has been passed to the formatter using the ancient procedure call interface used in Cucumber-Ruby v1 and v2. From Cucumber-Ruby v3 all other data to formatters has been passed using events.

Introduce an event AttachCalled to pass the data from "attach" and "log" calls from step definitions to event listeners like formatters.

Type of change

Please delete options that are not relevant.

  • Refactoring (improvements to code design or tooling that don't change behaviour)

Please add an entry to the relevant section of CHANGELOG.md as part of this pull request.

Checklist:

Your PR is ready for review once the following checklist is
complete. You can also add some checks if you want to.

  • Tests have been added for any changes to behaviour of the code
  • New and existing tests are passing locally and on CI
  • bundle exec rubocop reports no offenses
  • RDoc comments have been updated
  • CHANGELOG.md has been updated

* Remove the ancient procedure call interface from formatters completely
* Until now the data from "attach" and "log" calls from step definitions
  has been passed to the formatter using the ancient procedure call
  interface used in Cucumber-Ruby v1 and v2. From Cucumber-Ruby v3 all
  other data to formatters has been passed using events.
* Introduce an event AttachCalled to pass the data from "attach" and
  "log" calls from step definitions to event listeners like formatters.
Comment thread lib/cucumber/runtime/user_interface.rb

@luke-hill luke-hill left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes a lot of sense and removes some of the tech debt you mentioned. One QQ about some more stuff we can maybe cull

@StantonMatt

Copy link
Copy Markdown
Contributor

I ran a focused check around the attach/log event path on 174d2a49 with Ruby 3.3.11.

bundle exec cucumber features/docs/writing_support_code/attachments.feature features/docs/defining_steps/printing_messages.feature features/docs/writing_support_code/hooks/hook_order.feature
bundle exec cucumber features/docs/formatters/json_formatter.feature features/docs/formatters/pretty_formatter.feature
bundle exec rspec spec/cucumber/formatter/json_spec.rb spec/cucumber/formatter/message_spec.rb spec/cucumber/formatter/pretty_spec.rb spec/cucumber/glue/proto_world_spec.rb spec/cucumber/glue/step_definition_spec.rb
git diff --check origin/main...HEAD

Results:

  • docs attach/log/hook-order features: 7 scenarios, 55 steps, all passed
  • JSON + pretty formatter features: 12 scenarios, 119 steps, all passed
  • formatter/glue specs: 98 examples, 0 failures, 2 pending existing pending examples in ProtoWorld attachment specs
  • git diff --check passed
  • visible GitHub checks are also all green: 17/17, including RuboCop, CodeQL, and the full Ruby/platform test matrix

From that, I do not see a functional gap in the migration from visitor.attach/FanOut to configuration.notify(:attach_called, ...): the docs-level attach and log paths still reach message/json/pretty output, and the formatter/glue specs cover the MessageBuilder, JSON/pretty formatters, ProtoWorld, and step-definition bridge.

@luke-hill

Copy link
Copy Markdown
Contributor

@brasmusson can you write up some technical level changelog for this please. This is a great change and this makes a LOT more sense to me, so thankyou a LOT for this! 🎉

@brasmusson brasmusson merged commit 49c6dfc into main Jun 4, 2026
17 checks passed
@brasmusson brasmusson deleted the feature/attach-event branch June 4, 2026 16:49
luke-hill pushed a commit that referenced this pull request Jun 8, 2026
* Remove the ancient procedure call interface from formatters completely
* Until now the data from "attach" and "log" calls from step definitions
  has been passed to the formatter using the ancient procedure call
  interface used in Cucumber-Ruby v1 and v2. From Cucumber-Ruby v3 all
  other data to formatters has been passed using events.
* Introduce an event AttachCalled to pass the data from "attach" and
  "log" calls from step definitions to event listeners like formatters.
* Update Changelog.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants