djcrankypants / spock

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

Data values in where-block are not resolved in nested closures #286

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
If a derived parameter uses another parameter in a closure (for example in 
collection methods), groovy.lang.MissingPropertyException is thrown. The same 
construct works fine with regular variables.

Example:

class Example extends Specification {
    def "success"(){
        def x = [2, 4, 6]
        def y = [1, 2, 3, 4].findAll {it in x}

        expect:
        y == [2, 4]
    }

    def "fail"(){
        expect:
        y == [2, 4]

        where:
        x = [2, 4, 6]
        y = [1, 2, 3, 4].findAll {it in x}
    }
}

Is it related to http://code.google.com/p/spock/issues/detail?id=274 ? Or is 
this syntax not supposed to be supported in where-blocks?

Spock 0.7
Groovy 1.8.6

Original issue reported on code.google.com by nebehr.g...@gmail.com on 22 Nov 2012 at 12:36

GoogleCodeExporter commented 8 years ago
Looks like a limitation of the current where-block implementation.

Original comment by pnied...@gmail.com on 22 Nov 2012 at 12:42

GoogleCodeExporter commented 8 years ago

Original comment by pnied...@gmail.com on 10 Apr 2013 at 10:17