public DelegatingScript loadClosureBasedScript(final Closure<?> closure) {
    return new DelegatingScript() {
      @Override
      public Object run() {
        GroovyRuntimeUtil.invokeClosure(closure);
        return null;
      }

      @Override
      public void $setDelegate(Object delegate) {
        closure.setResolveStrategy(Closure.DELEGATE_FIRST);
        closure.setDelegate(delegate);
      }
    };
  }
For testing purposes. Do not use directly.
spock-core/src/main/java/org/spockframework/runtime/ConfigurationScriptLoader.java