Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Issue #458

  • Loading branch information...
commit 41c69d230523f00fcea927e7559955e6c2a12379 1 parent 9114f7c
@Luxor Luxor authored
Showing with 5 additions and 10 deletions.
  1. +5 −10 groovy/src/main/java/cucumber/runtime/groovy/GroovyBackend.java
View
15 groovy/src/main/java/cucumber/runtime/groovy/GroovyBackend.java
@@ -37,7 +37,7 @@
private final ClasspathResourceLoader classpathResourceLoader;
private Closure worldClosure;
- private Object groovyWorld;
+ private Object world;
private Glue glue;
private static GroovyShell createShell() {
@@ -97,6 +97,7 @@ public void setUnreportedStepExecutor(UnreportedStepExecutor executor) {
@Override
public void buildWorld() {
+ world = worldClosure == null ? new Object() : worldClosure.call();
}
private Script parse(Resource resource) {
@@ -113,7 +114,7 @@ private boolean isScript(Script script) {
@Override
public void disposeWorld() {
- this.groovyWorld = null;
+ this.world = null;
}
@Override
@@ -126,6 +127,7 @@ public void addStepDefinition(Pattern regexp, int timeoutMillis, Closure body) {
}
public void registerWorld(Closure closure) {
+ if (worldClosure != null) throw new CucumberException("World is already set");
worldClosure = closure;
}
@@ -138,7 +140,7 @@ public void addAfterHook(TagExpression tagExpression, int timeoutMillis, Closure
}
public void invoke(Closure body, Object[] args) throws Throwable {
- body.setDelegate(getGroovyWorld());
+ body.setDelegate(world);
try {
body.call(args);
} catch (InvokerInvocationException e) {
@@ -146,13 +148,6 @@ public void invoke(Closure body, Object[] args) throws Throwable {
}
}
- private Object getGroovyWorld() {
- if (groovyWorld == null) {
- groovyWorld = worldClosure == null ? new Object() : worldClosure.call();
- }
- return groovyWorld;
- }
-
private static StackTraceElement currentLocation() {
Throwable t = new Throwable();
StackTraceElement[] stackTraceElements = t.getStackTrace();
Please sign in to comment.
Something went wrong with that request. Please try again.