use of cucumber.runtime.io.Resource in project cucumber-jvm by cucumber.
the class FeatureBuilderTest method ignores_duplicate_features.
@Test
public void ignores_duplicate_features() throws IOException {
List<CucumberFeature> features = new ArrayList<CucumberFeature>();
FeatureBuilder builder = new FeatureBuilder(features);
String featurePath = "foo.feature";
Resource resource1 = createResourceMock(featurePath);
Resource resource2 = createResourceMock(featurePath);
builder.parse(resource1, NO_FILTERS);
builder.parse(resource2, NO_FILTERS);
assertEquals(1, features.size());
}
use of cucumber.runtime.io.Resource in project cucumber-jvm by cucumber.
the class FeatureBuilderTest method converts_windows_path_to_forward_slash.
@Test
public void converts_windows_path_to_forward_slash() 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("path/foo.feature", features.get(0).getPath());
}
use of cucumber.runtime.io.Resource in project cucumber-jvm by cucumber.
the class FormatterMissingLifecycleMethods method mockResource.
private void mockResource(ResourceLoader resourceLoader, String featurePath, String feature) throws IOException, UnsupportedEncodingException {
Resource resource1 = mock(Resource.class);
when(resource1.getPath()).thenReturn(featurePath);
when(resource1.getInputStream()).thenReturn(new ByteArrayInputStream(feature.getBytes("UTF-8")));
when(resourceLoader.resources(featurePath, ".feature")).thenReturn(asList(resource1));
}
use of cucumber.runtime.io.Resource in project cucumber-jvm by cucumber.
the class RhinoBackend method loadGlue.
@Override
public void loadGlue(Glue glue, List<String> gluePaths) {
this.glue = glue;
this.gluePaths = gluePaths;
for (String gluePath : gluePaths) {
for (Resource resource : resourceLoader.resources(gluePath, ".js")) {
runScript(resource);
}
}
}
use of cucumber.runtime.io.Resource in project cucumber-jvm by cucumber.
the class JRubyBackend method loadGlue.
@Override
public void loadGlue(Glue glue, List<String> gluePaths) {
this.glue = glue;
for (String gluePath : gluePaths) {
Iterable<Resource> resources = resourceLoader.resources(gluePath, ".rb");
List<Resource> resourcesWithEnvFirst = new ArrayList<Resource>();
for (Resource resource : resources) {
if (resource.getAbsolutePath().endsWith("env.rb")) {
resourcesWithEnvFirst.add(0, resource);
} else {
resourcesWithEnvFirst.add(resource);
}
}
for (Resource resource : resourcesWithEnvFirst) {
runScript(resource);
}
}
}
Aggregations