Open GoogleCodeExporter opened 8 years ago
I'm trying to match a Set as an argument, e.g.
class Container {
def call(Set<String> args) {
println args
}
}
def 'simple argument constraint'() {
setup:
def container = Mock(Container)
when:
container.call(['val1'] as Set)
then:
1 * container.call(['val1'] as Set)
}
But it results in a failure:
Too few invocations for:
1 * container.call(['val1'] as Set) (0 invocations)
Unmatched invocations (ordered by similarity):
1 * container.call(['val1'])
A little investigation shows that the constraint in TypeArgumentConstraint has
the type correct as Set, but the constraint is an EqualArgumentConstraint with
a List in it. I've tried some variations, like parentheses, but Spock is just
too smart. I can assign the argument to a variable first or use the closure
syntax for the argument, but I'd like to avoid doing it and keep it simple like
above. Any suggestions?
Original comment by quidr...@gmail.com
on 13 Oct 2014 at 4:27
A good workaround is to use `['val1'].toSet()`, rather than `['val1'] as Set`.
Original comment by pnied...@gmail.com
on 3 Mar 2015 at 2:56
Original issue reported on code.google.com by
quidr...@gmail.com
on 13 Oct 2014 at 4:26