bgarrels / spock

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

Description of unmatched invocations is blurry #380

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
It would be awesome to see which invocation has not been matched.

Lack of knowledge which exact invocation was not matched.

When having such a block of code in Spock spec:

        then:
        1 * repository.persist({Something something ->
            something.getAccount() == 12
            something.getAmount() == 10
            something.getLoan() == 123
            something.getClientId() == 1234
        })

when not matching for example getLoan() I receive such output:

Too few invocations for:

1 * repository.persist({Something something ->
            something.getAccount() == 12
            something.getAmount() == 10
            something.getLoan() == 123
            something.getClientId() == 1234
        })   (0 invocations)

Unmatched invocations (ordered by similarity):

1 * repository.persist(Something[some toString() output])

Original issue reported on code.google.com by marcin.g...@gmail.com on 7 Nov 2014 at 1:13

GoogleCodeExporter commented 9 years ago
Are you saying that you want to have more information on *why* a particular 
invocation didn't match? You can get that by rewriting to `1 * 
repository.persist(_) >> { assert ... }`, although the semantics aren't 
completely the same.

PS: The interaction in your example won't work as intended. An argument 
constraint is a single boolean expression, i.e. you'll need to connect all 
equals comparisons via `&&`.

Original comment by pnied...@gmail.com on 7 Nov 2014 at 1:22

GoogleCodeExporter commented 9 years ago
Ok, you're right - thx for the update!

Original comment by marcin.g...@gmail.com on 8 Nov 2014 at 8:24