I’ve been using the Spock framework for several years. While watching HLS’s presentation on Spock at InfoQ, he mentioned the old() method. I’d never heard of it and could not find it mentioned in the Spock documentation. A quick check of the source of the Specification class showed the feature, with the following javadoc:

Used in a then-block to access an expression’s value at the time just before the previous where-block was entered.

This is really useful when you can calculate the delta caused by a when block, so you don’t have to duplicate fragile literals. Here’s a quick example:

@Grapes(@Grab(group='org.spockframework', module='spock-core', version='0.7-groovy-2.0'))
import spock.lang.Specification

class MySpec extends Specification {

   def "Spock's old() method"() {
           def list = [1]
           list << 2
            list.size() == old(list.size()) + 1

The expression passed to the old() method is evaluated prior to the when block. This makes the test less fragile. If you happen to initilize the list to a different value, you won’t have to remember to update the assertion.