Skip to content

Commit b126fc8

Browse files
authored
bugfix: Handle Cucumber-Wire issue when parameter type cannot be specified 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
1 parent 64092da commit b126fc8

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ Please visit [cucumber/CONTRIBUTING.md](https://github.com/cucumber/cucumber/blo
1616
All logic contained in [compatibility](./compatibility) ([luke-hill](https://github.com/luke-hill))
1717

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

2023
### Removed
2124

lib/cucumber/formatter/message_builder.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def step_match_arguments(step)
132132
@step_definitions_by_test_step.step_match_arguments(step).map do |argument|
133133
Cucumber::Messages::StepMatchArgument.new(
134134
group: argument_group_to_message(argument.group),
135-
parameter_type_name: argument.parameter_type.name
135+
parameter_type_name: parameter_type_name(argument)
136136
)
137137
end
138138
end
@@ -145,6 +145,10 @@ def argument_group_to_message(group)
145145
)
146146
end
147147

148+
def parameter_type_name(step_match_argument)
149+
step_match_argument.parameter_type&.name if step_match_argument.respond_to?(:parameter_type)
150+
end
151+
148152
def on_test_run_started(*)
149153
message = Cucumber::Messages::Envelope.new(
150154
test_run_started: Cucumber::Messages::TestRunStarted.new(

0 commit comments

Comments
 (0)