Skip to content
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

Why do {word} parameters have to be surrounded by quotes? #54

Open
bluego-joe opened this issue Dec 7, 2021 · 1 comment
Open

Why do {word} parameters have to be surrounded by quotes? #54

bluego-joe opened this issue Dec 7, 2021 · 1 comment

Comments

@bluego-joe
Copy link

Using an example in the README, I have a step definition like Given I eat a {word}, which would match Given I eat a "worm" or Given I eat a 'worm'. But it doesn't match Given I eat a worm.

When using {int}s, {num}s and {float}s, it is not necessary to surround the values with quotes. Would it be possible to extend the same functionality to {word}? (but not {string})

@jonsamwell
Copy link
Owner

This is very much a range problem. With the quotes the regex knows to only find words with quotes. Without the quotes the word count could be unbounded?

So in the example Given I eat a 'worm' the existing regex RegExp("['|\"](\\w+)['|\"]") would work however if you had a step like

Given I eat {word} and it tasted like {word}

The regex above would match all words past the initial {word} parameter I think.

This is the existing parameter, not the regex

https://github.com/jonsamwell/dart_gherkin/blob/master/lib/src/gherkin/parameters/word_parameter.dart#L5

Feel free to have a play and see if you can come up with anything though!

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

No branches or pull requests

2 participants