Forgus / spock

Automatically exported from code.google.com/p/spock
0 stars 0 forks source link

with-block doesn't work for method conditions #324

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
...due to how they are implemented internally.

def list = [1,2,3]

expect:
with(list) {
    isEmpty()
}

groovy.lang.MissingMethodException: No signature of method: 
MyFirstSpec.isEmpty() is applicable for argument types: () values: []

Original issue reported on code.google.com by pnied...@gmail.com on 2 Aug 2013 at 6:30

GoogleCodeExporter commented 8 years ago
Groovy's "with" construct (including myFoo.with { ... }) can significantly 
reduce the amount of code and can significantly aid in comprehension. It would 
be fantastic if the assertions could reach into these blocks and apply their 
magic in there as well!

I don't know where to begin looking for where to add this capability, but if I 
could get pointed in the right direction, I might be able to provide a PR.

Original comment by cdes...@gmail.com on 26 Sep 2014 at 2:48

GoogleCodeExporter commented 8 years ago
That's already supported, just that you'll need to use Spock's own `with` 
method (e.g. `with(foo) { bar == 1 }`).

Original comment by pnied...@gmail.com on 26 Sep 2014 at 4:43

GoogleCodeExporter commented 8 years ago
(This issue is about an edge case where the assertion is a method call.)

Original comment by pnied...@gmail.com on 26 Sep 2014 at 4:44

GoogleCodeExporter commented 8 years ago

Original comment by pnied...@gmail.com on 1 Mar 2015 at 11:45