Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ArturGajowy/7422678 to your computer and use it in GitHub Desktop.
Save ArturGajowy/7422678 to your computer and use it in GitHub Desktop.
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
}
}
@vahidpaz
Copy link

vahidpaz commented Apr 3, 2014

Thanks that's exactly what I wanted to know. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment