use of org.jbehave.core.io.LoadFromClasspath in project jbehave-core by jbehave.
the class TransformingStoryParserBehaviour method shouldTransformAndParseStory.
@Test
public void shouldTransformAndParseStory() {
StoryParser delegate = new RegexStoryParser(new LoadFromClasspath(), new TableTransformers());
StoryTransformer transformer = new StoryTransformer() {
@Override
public String transform(String storyAsText) {
return storyAsText.replaceAll(",", "|");
}
};
StoryParser parser = new TransformingStoryParser(delegate, transformer);
String storyAsText = "Scenario: a scenario " + NL + "Given a scenario Given" + NL + "When I parse it to When" + NL + "And I parse it to And" + NL + "!-- And ignore me too" + NL + "Then I should get steps Then" + NL + "Examples:" + NL + ",Given,When,Then,And," + NL + ",Dato che,Quando,Allora,E,";
Story story = parser.parseStory(storyAsText);
assertThat(story.getScenarios().get(0).getExamplesTable().getRowCount(), equalTo(1));
}
use of org.jbehave.core.io.LoadFromClasspath in project jbehave-core by jbehave.
the class StoryRunnerBehaviour method configurationWithPendingStrategy.
private Configuration configurationWithPendingStrategy(StepCollector collector, StoryReporter reporter, PendingStepStrategy strategy) {
LoadFromClasspath resourceLoadder = new LoadFromClasspath();
RegexStoryParser storyParser = new RegexStoryParser(resourceLoadder, new TableTransformers());
return configurationWith(storyParser, resourceLoadder, reporter, collector, new RethrowingFailure(), strategy);
}
use of org.jbehave.core.io.LoadFromClasspath in project jbehave-core by jbehave.
the class StoryRunnerBehaviour method configurationWith.
private Configuration configurationWith(StoryReporter reporter, StepCollector collector, FailureStrategy failureStrategy) {
LoadFromClasspath resourceLoadder = new LoadFromClasspath();
RegexStoryParser storyParser = new RegexStoryParser(resourceLoadder, new TableTransformers());
return configurationWith(storyParser, resourceLoadder, reporter, collector, failureStrategy);
}
use of org.jbehave.core.io.LoadFromClasspath in project jbehave-core by jbehave.
the class ExamplesTableBehaviour method shouldParseTableWithDifferentSeparators.
@Test
public void shouldParseTableWithDifferentSeparators() {
String headerSeparator = "||";
String valueSeparator = "|";
String tableWithCustomSeparator = wikiTableAsString;
TableTransformers tableTransformers = new TableTransformers();
ParameterControls parameterControls = new ParameterControls();
ParameterConverters parameterConverters = new ParameterConverters(new LoadFromClasspath(), parameterControls, tableTransformers, true);
ExamplesTable table = new ExamplesTable(tableWithCustomSeparator, headerSeparator, valueSeparator, parameterConverters, parameterControls, tableTransformers);
assertThat(table.getHeaderSeparator(), equalTo(headerSeparator));
assertThat(table.getValueSeparator(), equalTo(valueSeparator));
ensureColumnOrderIsPreserved(table);
assertThat(table.asString(), equalTo(tableWithCustomSeparator));
}
use of org.jbehave.core.io.LoadFromClasspath in project jbehave-core by jbehave.
the class ExamplesTableBehaviour method shouldParseTableWithCustomTransformerSpecifiedViaProperties.
@Test
public void shouldParseTableWithCustomTransformerSpecifiedViaProperties() {
String tableWithProperties = "{transformer=myTransformer, trim=false}\n" + tableWithCommentsAsString;
TableTransformers tableTransformers = new TableTransformers();
tableTransformers.useTransformer("myTransformer", new TableTransformer() {
@Override
public String transform(String tableAsString, ExamplesTableProperties properties) {
return tableWithSpacesAsString;
}
});
ExamplesTable table = new ExamplesTableFactory(new LoadFromClasspath(), tableTransformers).createExamplesTable(tableWithProperties);
Properties properties = table.getProperties();
assertThat(properties.getProperty("transformer"), equalTo("myTransformer"));
ensureWhitespaceIsPreserved(table);
}
Aggregations