Seems that Groovy 'star-dot' operator doesn't like stubbed properties of Spock
doubles. Instead of returning the stubbed value, it returns an object. See the
attached test case (ready to run in Groovy console):
@Grapes([
@Grab(group='org.spockframework', module='spock-core', version='0.7-groovy-2.0'),
@Grab(group='cglib', module='cglib-nodep', version='3.1'),
])
class AmountHolderSpec extends spock.lang.Specification {
def "star-dot operator doesn't work with Spock doubles"() {
given:
def holders = [
Stub(AmountHolder) { it.amount >> 10.0 },
Stub(AmountHolder) { it.amount >> 20.0 },
]
expect:
holders[0].amount == 10.0 // fine
holders[1].amount == 20.0 // fine
holders*.amount == [10.0, 20.0] // failure
}
}
class AmountHolder {
BigDecimal getAmount() {
throw new IllegalArgumentException('should be stubbed')
}
}
Original issue reported on code.google.com by mgrys...@gmail.com on 22 Apr 2014 at 12:14
Original issue reported on code.google.com by
mgrys...@gmail.com
on 22 Apr 2014 at 12:14