Created
November 11, 2013 23:46
-
-
Save ArturGajowy/7422678 to your computer and use it in GitHub Desktop.
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
package com.example | |
import spock.lang.Ignore | |
import spock.lang.Specification | |
class StubAfterStubSpec extends Specification { | |
private static final DEFAULT_STUBBING = 42 | |
def stub | |
def setup() { | |
stub = Stub(java.util.concurrent.Callable) | |
stub.call() >> 42 | |
} | |
def "should return the value stubbed in setup"() { | |
expect: | |
stub.call() == DEFAULT_STUBBING | |
} | |
@Ignore('Nah, wont work :(') | |
def "should redefine the stub's response"() { | |
given: | |
def overriddenStubbing = 43 | |
stub.call() >> overriddenStubbing | |
when: | |
def result = stub.call() | |
then: | |
result == overriddenStubbing | |
} | |
def "should redefine the stub's response in then: block"() { | |
given: | |
def overriddenStubbing = 43 | |
when: | |
def result = stub.call() | |
then: | |
stub.call() >> overriddenStubbing | |
result == overriddenStubbing | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks that's exactly what I wanted to know. :-)