Spock Web Console

subscribe to the feed Subscribe
call (via #spockwebconsole)
tweet this script Tweet

call

Published 1 year ago by call with tags call
Actions  ➤ Edit In Console Back To Console Show/Hide Line Numbers View Recent Scripts
import spock.lang.*
class OrderedInteractionsSpec extends Specification { 
def "collaborators must be invoked in order"() {  
def coll1 = Mock(Collaborator)  
def coll2 = Mock(Collaborator)   
when:   
// try to reverse the order of these invocations and see what happens   
coll1.collaborate()   
coll2.collaborate()     

then:   
1 * coll1.collaborate()     

then:    1 * coll2.collaborate() 
}
} 

interface Collaborator { 
def collaborate()
}