-
-
Notifications
You must be signed in to change notification settings - Fork 689
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cucumber-expressions: fix captured empty strings being undefined #754
Conversation
Thanks @davidjgoss! As soon as this is ported to Java/Ruby/Go as well we'll merge this to master so it can go into the next release. |
Thanks - happy to pick up the Java one as part of this PR, I'm less familiar with Ruby and Go though |
@davidjgoss thanks! Don't worry about Ruby and Go. We'll merge this to an |
Correction: This is already on a branch in the main repo, so we'll all just keep working on that branch. It's prefixed |
8f3b22f
to
761b0f1
Compare
Java implementation did not suffer from the issue, but added the same tests in the same place so it's covered. |
Hi all, just thought I'd chime in here. I've used this feature before in cucumber-ruby. So I've merged in the documentation PR alongside this. The ruby implementation currently works. i.e. a step defined as
I'm not sure on the test coverage, but I know we had some zero-or-more capture lengths when I did a lot of the testing of this when fixing up the ?! issue I did ages ago. EDIT: Also the capture is also correct, it's not |
Took a run at adding the tests for Go; seems to also be fine already. |
First foray into Go? Good stuff! |
I see the checkbox for Ruby above is checked, but AFAIK there are no tests proving this works on Ruby. We need tests, anectdotal evidence isn't sufficient as it can allow regressions to creep in. Did you check the box @luke-hill? |
@aslakhellesoy ah sorry I think that was me. Unchecked. Also .NET doesn't seem to be a thing for expressions so crossed that one off. |
Yeh I think (I'm not sure when or how), that ruby and go were either fixed or were working. But again, not 100% / don't know about tests. Fully agree we should add some, but I've merged in the docs PR, as this is default behaviour in the intended usage. |
Okay Ruby tests pushed - all langs now covered |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔝 stuff
Am I good to merge this? |
Hi @davidjgoss yes please go ahead! Please remember to update |
Summary
Changes to stop captures of empty string parameters being filtered off when interrogating the group, and to the specific transform function so that falsy values are handled
Details
Added a small guard to the transform function for the "string" parameter type, so falsy values are switched for an empty string.
This was enough for the tests to pass, but at the root there was still the issue of this value being undefined, due to the logic in the getter for
children
in theGroup
class.What
children
looks like when the string parameter is empty:What children looks like when the string parameter is non-empty:
Best I can tell, the previous code used
value !== null
as the heuristic to filter off the first item; I've changed it tostart !== undefined
. Although to be fair it didn't seem to be affecting anything else, so technically the guard in the transform is enough.Motivation and Context
Fixes #746
Essentially, empty strings are a valid value for a
{string}
parameter, however these were coming through to the transformer as undefined and then causing an error when the function was expecting a string with areplace
method. This was called out as a regression, as it used to work.How Has This Been Tested?
Added unit tests to
CucumberExpressionTest
, those all other tests passing.Confirmed it resolves the issue on the reporter's test case project.
Types of changes
Checklist:
- [ ] The change has been ported to .NET.I haven't checked the behaviour of the other language implementations yet - will do that next but wanted to get early review on this change.