Skip to content

Commit

Permalink
feat: include dsl
Browse files Browse the repository at this point in the history
Signed-off-by: Joke de Buhr <[email protected]>
  • Loading branch information
joke committed Nov 20, 2022
1 parent 906b89f commit be91f3e
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions spock-deepmock/src/main/resources/dsld/spk.dsld
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package dsld

import org.codehaus.groovy.ast.expr.*

assertVersion(groovyEclipse: "2.7.2") // tested against this version

// DeepMock(Foo) { /* delegates to instance of type Foo /* }
// works for all mock factory methods and all overloads that include a type
contribute(
enclosingClass(subType("spock.lang.Specification")) &
enclosingCallDeclaringType("spock.mock.MockingApi") &
bind(theCalls: enclosingCall(name("DeepMock") | name("GroovyDeepMock") &
enclosingClosure()) {
def args = theCalls.iterator().next().arguments.expressions
def mockType = args.find { it instanceof ClassExpression }
if (mockType) {
delegatesTo(mockType)
}
}

0 comments on commit be91f3e

Please sign in to comment.