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

Line continuations for rust step definitions #179

Merged
merged 3 commits into from
Jan 16, 2024

Conversation

kieran-ryan
Copy link
Member

@kieran-ryan kieran-ryan commented Jan 15, 2024

🤔 What's changed?

Support line continuation characters for step definition patterns written in rust.

⚡️ What's your motivation?

Fixes cucumber/vscode#116.

Screenshot 2024-01-15 at 22 02 57

🏷️ What kind of change is this?

  • 🐛 Bug fix (non-breaking change which fixes a defect)

♻️ Anything particular you want feedback on?

What gherkin text will match the below step definition pattern where there are characters on the line after the line continuation? cucumber-rs does not throw any error for this pattern; however, was unable to find a matching gherkin test step.

#[given("a line continuation \
")]
fn hungry_cat(world: &mut AnimalWorld) {
    world.cat.hungry = true;
}

📋 Checklist:

  • I agree to respect and uphold the Cucumber Community Code of Conduct
  • I've changed the behaviour of the code
    • I have added/updated tests to cover my changes.
  • Users should know about my change
    • I have added an entry to the "Unreleased" section of the CHANGELOG, linking to this pull request.

@kieran-ryan kieran-ryan added the 🐛 bug Defect / Bug label Jan 15, 2024
@kieran-ryan kieran-ryan self-assigned this Jan 15, 2024
@kieran-ryan kieran-ryan changed the title Fix line continuations for rust step definitions Line continuations for rust step definitions Jan 15, 2024
@kieran-ryan
Copy link
Member Author

Behaviour of cucumber-rs from Anything particular you want feedback on? has been validated with great help from @tyranron - thank you - see cucumber-rs/cucumber#319.

A rust step definition pattern containing trailing whitespace cannot match a gherkin test step as the gherkin parser strips trailing whitespace. Modifying cucumber-rs to explicitly inform the user of how to fix such cases is a possibility through a pull request. These cases are thus appropriately accounted for in the unit tests of this pull request.

#[given("a line continuation \
")]
fn hungry_cat(world: &mut AnimalWorld) {
    world.cat.hungry = true;
}

@kieran-ryan kieran-ryan merged commit c8d94c9 into main Jan 16, 2024
6 checks passed
@kieran-ryan kieran-ryan deleted the fix-rust-line-continuations branch January 16, 2024 20:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Defect / Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Patterns with line breaks are not matched as expected
2 participants