Skip to content

Commit

Permalink
bugfix: Handle Cucumber-Wire issue when parameter type cannot be spec…
Browse files Browse the repository at this point in the history
…ified on Envelope (#1746)

* Handle NME from cucumber-wire
- When step match argument cannot detect the parameter type name, return `nil` and then have the optional param fed as `nil`
- When there is no parameter type (Because of legacy system), then return `nil` and have the optional param fed as `nil`

* Add changelog
  • Loading branch information
luke-hill committed Jan 12, 2024
1 parent 64092da commit b126fc8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ Please visit [cucumber/CONTRIBUTING.md](https://github.com/cucumber/cucumber/blo
All logic contained in [compatibility](./compatibility) ([luke-hill](https://github.com/luke-hill))

### Fixed
- Fix a situation whereby the step definition message will omit the parameter-type name when it cannot be inferred
(This fixes an issue in cucumber-wire when passing legacy steps down the wire)
([#1746](https://github.com/cucumber/cucumber-ruby/pull/1746) [luke-hill](https://github.com/luke-hill))

### Removed

Expand Down
6 changes: 5 additions & 1 deletion lib/cucumber/formatter/message_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def step_match_arguments(step)
@step_definitions_by_test_step.step_match_arguments(step).map do |argument|
Cucumber::Messages::StepMatchArgument.new(
group: argument_group_to_message(argument.group),
parameter_type_name: argument.parameter_type.name
parameter_type_name: parameter_type_name(argument)
)
end
end
Expand All @@ -145,6 +145,10 @@ def argument_group_to_message(group)
)
end

def parameter_type_name(step_match_argument)
step_match_argument.parameter_type&.name if step_match_argument.respond_to?(:parameter_type)
end

def on_test_run_started(*)
message = Cucumber::Messages::Envelope.new(
test_run_started: Cucumber::Messages::TestRunStarted.new(
Expand Down

0 comments on commit b126fc8

Please sign in to comment.