cucumber / language-service

Cucumber Language Service
MIT License
18 stars 27 forks source link

Line continuations for rust step definitions #179

Closed kieran-ryan closed 10 months ago

kieran-ryan commented 10 months ago

🤔 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?

♻️ 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:

kieran-ryan commented 10 months ago

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;
}