You need to use any[MonetaryValue]
. Here is a fully working example:
class TestSpec extends Specification with Mockito { def is = s2"""
test ${
val voucher: Voucher = mock[Voucher]
// the asInstanceOf cast is ugly and
// I need to find ways to remove that
voucher.aMethod(any[MonetaryValue]) answers { m => m.asInstanceOf[MonetaryValue].value + 1}
voucher.aMethod(MonetaryValue(2)) === 3
}
"""
}
trait Voucher {
def aMethod(m: MonetaryValue) = m.value
}
case class MonetaryValue(value: Int = 1)