Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Tests/Reqnroll.Specs/Drivers/Parser/ParserDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,28 @@ public void AssertErrors(List<ExpectedError> expectedErrors)
}
}

public void AssertTableHasColumns(params string[] expectedColumns)
{
ParsedDocument.Should().NotBeNull("The parsing was not successful");

var scenario = ParsedDocument.ReqnrollFeature.Children.OfType<Scenario>().FirstOrDefault();
scenario.Should().NotBeNull("No scenario found in the parsed document");

var step = scenario.Steps.FirstOrDefault();
step.Should().NotBeNull("No step found in the scenario");

var table = step.Argument as Gherkin.Ast.DataTable;
table.Should().NotBeNull("No table argument found in the step");

var headerRow = table.Rows.FirstOrDefault();
headerRow.Should().NotBeNull("Table has no rows");

var actualColumns = headerRow.Cells.Select(c => c.Value).ToList();

actualColumns.Should().BeEquivalentTo(expectedColumns,
"the parsed table should have the expected columns");
}

public void SaveSerializedFeatureTo(string fileName)
{
ParsedDocument.Should().NotBeNull("The parsing was not successful");
Expand Down
20 changes: 20 additions & 0 deletions Tests/Reqnroll.Specs/Features/Parser/ParsingErrors.feature
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,23 @@ Scenario: Duplicated background
| line | error |
| 6 | got 'Background:' |

Scenario: Table without trailing delimiter on any row
# This test demonstrates issue #964: when all rows are missing the trailing pipe delimiter,
# the parser silently ignores the last column instead of reporting an error.
# Expected behavior: should report an error or warning about missing trailing delimiter
# Actual behavior: no error is reported, and the last column is silently ignored
Given there is a Gherkin file as
"""
Feature: Table without trailing delimiter

Scenario: Table without trailing delimiter
Given a table
| EffectiveDate | InterestRate
| 1999-01-01 | 10.00
"""
When the file is parsed
Then no parsing error is reported
And the parsed table has only the following columns
| column |
| EffectiveDate |

7 changes: 7 additions & 0 deletions Tests/Reqnroll.Specs/StepDefinitions/GherkinParserSteps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,12 @@ public void ThenTheTheFollowingErrorsAreProvided(List<ExpectedError> expectedErr
{
_parserDriver.AssertErrors(expectedErrors);
}

[Then(@"the parsed table has only the following columns")]
public void ThenTheParsedTableHasOnlyTheFollowingColumns(Table table)
{
var expectedColumns = table.Rows.Select(r => r["column"]).ToArray();
_parserDriver.AssertTableHasColumns(expectedColumns);
}
}
}
Loading