commit 766ee06c67d08505c64a33f4030f379ec1c038ea
Author: Mauro Talevi <[email protected]>
AuthorDate: Sat Jun 2 16:55:19 2012 +0100
Commit: Mauro Talevi <[email protected]>
CommitDate: Sat Jun 2 16:57:55 2012 +0100
JBEHAVE-782: Fixed parsing of scenario.
diff --git
a/jbehave-core/src/main/java/org/jbehave/core/parsers/RegexStoryParser.java
b/jbehave-core/src/main/java/org/jbehave/core/parsers/RegexStoryParser.java
index 3150c52..ddcd2a4 100755
--- a/jbehave-core/src/main/java/org/jbehave/core/parsers/RegexStoryParser.java
+++ b/jbehave-core/src/main/java/org/jbehave/core/parsers/RegexStoryParser.java
@@ -133,7 +133,7 @@ public class RegexStoryParser implements StoryParser {
List<String> scenarios = new ArrayList<String>();
String scenarioKeyword = keywords.scenario();
- // remove anything after scenario keyword, if found
+ // use text after scenario keyword, if found
if (StringUtils.contains(storyAsText, scenarioKeyword)) {
storyAsText = StringUtils.substringAfter(storyAsText,
scenarioKeyword);
}
@@ -143,12 +143,17 @@ public class RegexStoryParser implements StoryParser {
scenarios.add(scenarioKeyword + "\n" + scenarioAsText);
}
}
+
return scenarios;
}
private Scenario parseScenario(String scenarioAsText) {
String title = findScenarioTitle(scenarioAsText);
- String scenarioWithoutTitle = removeStart(scenarioAsText, title);
+ String scenarioWithoutKeyword = removeStart(scenarioAsText,
keywords.scenario()).trim();
+ String scenarioWithoutTitle = removeStart(scenarioWithoutKeyword,
title);
+ if ( !scenarioWithoutTitle.startsWith("\n") ){ // always ensure
scenario starts with newline
+ scenarioWithoutTitle = "\n" + scenarioWithoutTitle;
+ }
Meta meta = findScenarioMeta(scenarioWithoutTitle);
ExamplesTable examplesTable = findExamplesTable(scenarioWithoutTitle);
GivenStories givenStories = findGivenStories(scenarioWithoutTitle);