Spock Web Console

subscribe to the feed Subscribe
Stubbing method issue (via #spockwebconsole)
tweet this script Tweet

Stubbing method issue

Published 2 years ago by topr with tags bug issue stub
Actions  ➤ Edit In Console Back To Console Show/Hide Line Numbers View Recent Scripts
import spock.lang.*

// Hit 'Run Script' below
class MyFirstSpec extends Specification {

   def 'stub a method with collection as argument'() {
      given:
      def input = [1, 2, 3]
      def capturedArgument
      List listStub = Stub()
      listStub.addAll(input) >> {
         capturedArgument = it
      }

      when:
      listStub.addAll(input)

      then:
      input.class == capturedArgument.class
   }
}