Search in sources :

Example 11 with Resource

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());
}
Also used : CucumberFeature(cucumber.runtime.model.CucumberFeature) ArrayList(java.util.ArrayList) Resource(cucumber.runtime.io.Resource) Test(org.junit.Test)

Example 12 with Resource

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());
}
Also used : CucumberFeature(cucumber.runtime.model.CucumberFeature) Resource(cucumber.runtime.io.Resource) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 13 with Resource

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));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) Resource(cucumber.runtime.io.Resource)

Example 14 with Resource

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);
        }
    }
}
Also used : Resource(cucumber.runtime.io.Resource)

Example 15 with 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);
        }
    }
}
Also used : Resource(cucumber.runtime.io.Resource) ArrayList(java.util.ArrayList) DocString(gherkin.formatter.model.DocString)

Aggregations

Resource (cucumber.runtime.io.Resource)17 ArrayList (java.util.ArrayList)9 CucumberFeature (cucumber.runtime.model.CucumberFeature)6 ByteArrayInputStream (java.io.ByteArrayInputStream)6 Test (org.junit.Test)3 CucumberException (cucumber.runtime.CucumberException)2 FeatureBuilder (cucumber.runtime.FeatureBuilder)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 AssetManager (android.content.res.AssetManager)1 ResourceLoader (cucumber.runtime.io.ResourceLoader)1 DocString (gherkin.formatter.model.DocString)1 Binding (groovy.lang.Binding)1 Script (groovy.lang.Script)1 Gosu (gw.lang.Gosu)1 Map (java.util.Map)1 SWClassLoader (org.apache.openejb.arquillian.openejb.SWClassLoader)1 InvokerInvocationException (org.codehaus.groovy.runtime.InvokerInvocationException)1 Archive (org.jboss.shrinkwrap.api.Archive)1