Skip to content

Commit

Permalink
Fix EmbeddedSpecRunner.runFeatureBody language prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
leonard84 committed Oct 3, 2017
1 parent c51c45c commit e5afc5d
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions spock-core/src/main/groovy/spock/util/EmbeddedSpecRunner.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,15 @@

package spock.util

import org.intellij.lang.annotations.Language
import org.junit.runner.notification.RunListener
import org.junit.runner.*

import org.spockframework.util.NotThreadSafe
import org.spockframework.util.IThrowableFunction
import org.spockframework.runtime.RunContext
import org.spockframework.runtime.ConfigurationScriptLoader
import org.spockframework.runtime.*
import org.spockframework.util.*

import java.lang.reflect.Modifier

import org.intellij.lang.annotations.Language
import org.junit.runner.*
import org.junit.runner.notification.RunListener

/**
* Utility class that allows to run (fragments of) specs programmatically.
* Mainly intended for spec'ing Spock itself.
Expand All @@ -40,7 +38,7 @@ class EmbeddedSpecRunner {
boolean throwFailure = true

List<RunListener> listeners = []

Closure configurationScript = null
List<Class> extensionClasses = []
boolean inheritParentExtensions = true
Expand Down Expand Up @@ -103,12 +101,13 @@ class EmbeddedSpecRunner {
runClass(compiler.compileSpecBody(source))
}

Result runFeatureBody(@Language(value = 'Groovy', prefix = "def 'a feature'() { ", suffix = '\n }')
Result runFeatureBody(@Language(value = 'Groovy',
prefix = "class ASpec extends spock.lang.Specification { def 'a feature'() { ", suffix = '\n } }')
String source) {
runClass(compiler.compileFeatureBody(source))
}

def withNewContext(Closure block) {
def <T> T withNewContext(Closure<T> block) {
def context = RunContext.get()
def newContextName = context.name + "/EmbeddedSpecRunner"
def newSpockUserHome = new File(context.spockUserHome, "EmbeddedSpecRunner")
Expand Down

0 comments on commit e5afc5d

Please sign in to comment.