Created
February 17, 2015 16:39
-
-
Save marcingrzejszczak/6c8067edae50e82db322 to your computer and use it in GitHub Desktop.
Calling assertion block from where
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AssertionFromWhereSpec extends Specification { | |
def 'should execute closure from where'() { | |
given: | |
Dupa dupa = Mock() | |
Cyce cyce = new Cyce(dupa) | |
when: | |
cyce.asd() | |
then: | |
1 * dupa.cosTam(*_) >> { args -> | |
assertion(args[1]) | |
return 1 | |
} | |
where: | |
var1 | assertion | |
'asd' | { int value -> assert value > 100 } | |
} | |
class Cyce { | |
private Dupa dupa | |
Cyce(Dupa dupa) { | |
this.dupa = dupa | |
} | |
int asd() { | |
return dupa.cosTam('a', 123) | |
} | |
} | |
interface Dupa { | |
int cosTam(String a, Integer b) | |
} | |
class DupaImpl implements Dupa { | |
int cosTam(String a, Integer b) { | |
return 1 | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment