You can capture an argument as follows:
// must be declared before when-block (or inside Specification.interaction {})
def captured
when:
...
then:
1 * mock.doNetworkCall(...) >> { record, recordClass ->
// save the argument
captured = record
...
}
// use the saved argument
captured == ...
That said, often there is a simpler solution such as checking the expected record right in the argument constraint (e.g. ...doNetworkCall( { it == ... } )
).