Skip to content

Commit

Permalink
JBEHAVE-1606 Remove duplicate handling of table meta
Browse files Browse the repository at this point in the history
  • Loading branch information
uarlouski committed Nov 21, 2024
1 parent bfbff3c commit 263c66b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -402,9 +402,8 @@ private Pattern findingScenarioTitle() {

private Pattern findingScenarioMeta() {
String startingWords = concatenateStartingWords();
return compile(
".*" + keywords().meta() + "(.*?)\\s*(" + keywords().givenStories() + "|" + startingWords + "|$).*",
DOTALL);
return compile(".*^\\s*" + keywords().meta() + "(.*?)\\s*(" + keywords().givenStories() + "|" + startingWords
+ "|$).*", DOTALL);
}

private Pattern findingScenarioGivenStories() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,29 @@ void shouldParseStoryWithScenarioTitleGivenStoriesAndStepsContainingKeywordsNotA
+ NL + "|Dado que|Quando|Então|E|"
+ NL));
}


@Test
void shouldNotParseExamplesTableMetaAsScenarioMeta() {
String wholeStory = "Scenario: Scenario with examples table containing meta"
+ NL + "Given a scenario Given"
+ NL + "Examples:"
+ NL + "|Meta: |value|"
+ NL + "|@number 1|one |"
+ NL + "|@number 2|two |" + NL;
Story story = parser.parseStory(wholeStory, storyPath);

Scenario scenario = story.getScenarios().get(0);
assertThat(scenario.getTitle(), equalTo("Scenario with examples table containing meta"));
List<String> steps = scenario.getSteps();
assertThat(steps.get(0), equalTo("Given a scenario Given"));
assertThat(scenario.getExamplesTable().asString(),
equalTo("|Meta:|value|"
+ NL + "|@number 1|one|"
+ NL + "|@number 2|two|"
+ NL));
assertThat(scenario.getMeta().isEmpty(), is(true));
}

@Test
void shouldParseStoryWithLifecycle() {
String wholeStory = "Lifecycle: "
Expand Down

0 comments on commit 263c66b

Please sign in to comment.