use of org.jbehave.core.model.Meta in project jbehave-core by jbehave.
the class RegexStoryParserBehaviour method shouldParseStoryWithMetaAndLifecycle.
@Test
public void shouldParseStoryWithMetaAndLifecycle() {
String wholeStory = "Meta: @skip @theme parsing" + NL + "Lifecycle:" + NL + "Before:" + NL + "Given a step before each scenario" + NL + "And another before step" + NL + "Scenario: A scenario" + NL + "Meta: @author Mauro" + NL + "Given a step " + NL + "Scenario: Another scenario" + NL + "Meta: @author Paul" + NL + "Given another step ";
Story story = parser.parseStory(wholeStory, storyPath);
assertThat(story.getPath(), equalTo(storyPath));
Meta storyMeta = story.getMeta();
assertThat(storyMeta.getProperty("theme"), equalTo("parsing"));
assertThat(storyMeta.getProperty("skip"), equalTo(EMPTY));
assertThat(storyMeta.getProperty("unknown"), equalTo(EMPTY));
Lifecycle lifecycle = story.getLifecycle();
assertThat(lifecycle.getBeforeSteps().size(), equalTo(2));
List<Scenario> scenarios = story.getScenarios();
assertThat(scenarios.get(0).getTitle(), equalTo("A scenario"));
assertThat(scenarios.get(0).getMeta().getProperty("author"), equalTo("Mauro"));
assertThat(scenarios.get(1).getTitle(), equalTo("Another scenario"));
assertThat(scenarios.get(1).getMeta().getProperty("author"), equalTo("Paul"));
}
use of org.jbehave.core.model.Meta in project jbehave-core by jbehave.
the class StoryMapperBehaviour method shouldMapStoriesAllowedByFilter.
@Test
public void shouldMapStoriesAllowedByFilter() throws Throwable {
// Given
Meta meta1 = mock(Meta.class, "meta1");
Story story1 = new Story("/path/to/story1", Description.EMPTY, meta1, Narrative.EMPTY, asList(new Scenario("scenario1", meta1)));
Meta meta2 = mock(Meta.class, "meta2");
Story story2 = new Story("/path/to/story2", Description.EMPTY, meta2, Narrative.EMPTY, asList(new Scenario("scenario2", meta2)));
MetaFilter filter = mock(MetaFilter.class);
String filterAsString = "-some property";
// When
StoryMapper mapper = new StoryMapper();
when(meta1.inheritFrom(meta1)).thenReturn(meta1);
when(meta2.inheritFrom(meta2)).thenReturn(meta2);
when(filter.allow(meta1)).thenReturn(false);
when(filter.allow(meta2)).thenReturn(true);
when(filter.asString()).thenReturn(filterAsString);
mapper.map(story1, filter);
mapper.map(story2, filter);
// Then
StoryMaps storyMaps = mapper.getStoryMaps();
assertThat(storyMaps.getMaps().size(), equalTo(1));
StoryMap storyMap = storyMaps.getMap(filterAsString);
assertThat(storyMap.getMetaFilter(), equalTo(filterAsString));
assertThat(storyMap.getStories().get(0).getPath(), equalTo(story2.getPath()));
assertThat(storyMap.getStoryPaths(), equalTo(asList(story2.getPath())));
}
use of org.jbehave.core.model.Meta in project jbehave-core by jbehave.
the class TemplateableOutput method beforeScenario.
@Override
public void beforeScenario(Scenario scenario) {
if (this.outputScenario.currentExample == null) {
this.outputScenario = new OutputScenario();
}
this.outputScenario.title = scenario.getTitle();
this.scope = Scope.SCENARIO;
Meta meta = scenario.getMeta();
if (!meta.isEmpty()) {
this.outputScenario.meta = new OutputMeta(meta);
}
}
use of org.jbehave.core.model.Meta in project jbehave-core by jbehave.
the class RegexStoryParser method parseScenario.
private Scenario parseScenario(String scenarioAsText) {
String title = findScenarioTitle(scenarioAsText);
String scenarioWithoutKeyword = removeStart(scenarioAsText, keywords.scenario()).trim();
String scenarioWithoutTitle = removeStart(scenarioWithoutKeyword, title);
scenarioWithoutTitle = startingWithNL(scenarioWithoutTitle);
Meta meta = findScenarioMeta(scenarioWithoutTitle);
ExamplesTable examplesTable = findExamplesTable(scenarioWithoutTitle);
GivenStories givenStories = findScenarioGivenStories(scenarioWithoutTitle);
if (givenStories.requireParameters()) {
givenStories.useExamplesTable(examplesTable);
}
List<String> steps = findSteps(scenarioWithoutTitle);
return new Scenario(title, meta, givenStories, examplesTable, steps);
}
use of org.jbehave.core.model.Meta in project jbehave-core by jbehave.
the class RegexStoryParser method parseStory.
public Story parseStory(String storyAsText, String storyPath) {
Description description = parseDescriptionFrom(storyAsText);
Meta meta = parseStoryMetaFrom(storyAsText);
Narrative narrative = parseNarrativeFrom(storyAsText);
GivenStories givenStories = parseGivenStories(storyAsText);
Lifecycle lifecycle = parseLifecycle(storyAsText);
List<Scenario> scenarios = parseScenariosFrom(storyAsText);
Story story = new Story(storyPath, description, meta, narrative, givenStories, lifecycle, scenarios);
if (storyPath != null) {
story.namedAs(new File(storyPath).getName());
}
return story;
}
Aggregations