Skip to content

Commit 5ca4b87

Browse files
authored
JBEHAVE-1606 Handle dynamic table meta only at scenario execution level (jbehave#85)
1 parent a41219c commit 5ca4b87

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

jbehave-core/src/main/java/org/jbehave/core/parsers/RegexStoryParser.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,9 +402,8 @@ private Pattern findingScenarioTitle() {
402402

403403
private Pattern findingScenarioMeta() {
404404
String startingWords = concatenateStartingWords();
405-
return compile(
406-
".*" + keywords().meta() + "(.*?)\\s*(" + keywords().givenStories() + "|" + startingWords + "|$).*",
407-
DOTALL);
405+
return compile(".*^\\s*" + keywords().meta() + "(.*?)\\s*(" + keywords().givenStories() + "|" + startingWords
406+
+ "|$).*", DOTALL);
408407
}
409408

410409
private Pattern findingScenarioGivenStories() {

jbehave-core/src/test/java/org/jbehave/core/parsers/RegexStoryParserBehaviour.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,29 @@ void shouldParseStoryWithScenarioTitleGivenStoriesAndStepsContainingKeywordsNotA
305305
+ NL + "|Dado que|Quando|Então|E|"
306306
+ NL));
307307
}
308-
308+
309+
@Test
310+
void shouldNotParseExamplesTableMetaAsScenarioMeta() {
311+
String wholeStory = "Scenario: Scenario with examples table containing meta"
312+
+ NL + "Given a scenario Given"
313+
+ NL + "Examples:"
314+
+ NL + "|Meta: |value|"
315+
+ NL + "|@number 1|one |"
316+
+ NL + "|@number 2|two |" + NL;
317+
Story story = parser.parseStory(wholeStory, storyPath);
318+
319+
Scenario scenario = story.getScenarios().get(0);
320+
assertThat(scenario.getTitle(), equalTo("Scenario with examples table containing meta"));
321+
List<String> steps = scenario.getSteps();
322+
assertThat(steps.get(0), equalTo("Given a scenario Given"));
323+
assertThat(scenario.getExamplesTable().asString(),
324+
equalTo("|Meta:|value|"
325+
+ NL + "|@number 1|one|"
326+
+ NL + "|@number 2|two|"
327+
+ NL));
328+
assertThat(scenario.getMeta().isEmpty(), is(true));
329+
}
330+
309331
@Test
310332
void shouldParseStoryWithLifecycle() {
311333
String wholeStory = "Lifecycle: "

0 commit comments

Comments
 (0)