use of cucumber.runtime.io.Resource in project cucumber-jvm by cucumber.
the class CucumberFeature method loadFromFeaturePath.
private static void loadFromFeaturePath(FeatureBuilder builder, ResourceLoader resourceLoader, String featurePath, final List<Object> filters, boolean failOnNoResource) {
PathWithLines pathWithLines = new PathWithLines(featurePath);
ArrayList<Object> filtersForPath = new ArrayList<Object>(filters);
filtersForPath.addAll(pathWithLines.lines);
Iterable<Resource> resources = resourceLoader.resources(pathWithLines.path, ".feature");
if (failOnNoResource && !resources.iterator().hasNext()) {
throw new IllegalArgumentException("No resource found for: " + pathWithLines.path);
}
for (Resource resource : resources) {
builder.parse(resource, filtersForPath);
}
}
use of cucumber.runtime.io.Resource in project cucumber-jvm by cucumber.
the class FeatureBuilderTest method works_when_path_and_uri_are_the_same.
@Test
public void works_when_path_and_uri_are_the_same() throws IOException {
char fileSeparatorChar = '/';
String featurePath = "path" + fileSeparatorChar + "foo.feature";
Resource resource = createResourceMock(featurePath);
List<CucumberFeature> features = new ArrayList<CucumberFeature>();
FeatureBuilder builder = new FeatureBuilder(features, fileSeparatorChar);
builder.parse(resource, NO_FILTERS);
assertEquals(1, features.size());
assertEquals(featurePath, features.get(0).getPath());
}
use of cucumber.runtime.io.Resource in project cucumber-jvm by cucumber.
the class FeatureBuilderTest method createResourceMock.
private Resource createResourceMock(String featurePath) throws IOException {
Resource resource = mock(Resource.class);
when(resource.getPath()).thenReturn(featurePath);
ByteArrayInputStream feature = new ByteArrayInputStream("Feature: foo".getBytes("UTF-8"));
when(resource.getInputStream()).thenReturn(feature);
return resource;
}
use of cucumber.runtime.io.Resource in project cucumber-jvm by cucumber.
the class AndroidResourceLoader method resources.
@Override
public Iterable<Resource> resources(final String path, final String suffix) {
try {
final List<Resource> resources = new ArrayList<Resource>();
final AssetManager assetManager = context.getAssets();
addResourceRecursive(resources, assetManager, path, suffix);
return resources;
} catch (final IOException e) {
throw new CucumberException("Error loading resources from " + path + " with suffix " + suffix, e);
}
}
use of cucumber.runtime.io.Resource in project cucumber-jvm by cucumber.
the class GosuBackend method loadGlue.
@Override
public void loadGlue(Glue glue, List<String> gluePaths) {
this.glue = glue;
GlueSource source = new GlueSource();
for (String gluePath : gluePaths) {
for (Resource glueScript : resourceLoader.resources(gluePath, ".gsp")) {
source.addGlueScript(glueScript);
}
}
Gosu gosu = new Gosu();
gosu.start(source.toArgInfo());
}
Aggregations