Midje icon indicating copy to clipboard operation
Midje copied to clipboard

No detailed error message using `has every?`

Open matthewgertner opened this issue 10 years ago • 2 comments

I'd like to test a sequence of maps against a schema I've defined using Prismatic schema. I get nice detailed error output from vice if I say something like:

my-object => (matches MySchema)

However, if I test the whole sequence like this:

my-objects => (has every? (matches MySchema))

it tells me when it fails but doesn't say why. All I see is that such-and-such a value did not match (has every (matches MySchema)) not that some required property is missing or has the wrong type or whatever.

Am I doing something wrong? Is this a Midje bug? Or is it by design?

matthewgertner avatar Oct 28 '14 12:10 matthewgertner

To clarify, when I say:

(first my-objects) => (matches MySchema)

I get output like:

The checker said this about the reason:
    {:project (not (instance? java.lang.Integer "dakrone/clj-http"))}

So I can see exact what went wrong (i.e. :project is not an integer although that is what the schema specifies). When I say:

my-objects => (has every? (matches MySchema))

I see:

Actual result did not agree with the checking function.
    Actual result: ...
Checking function: (has every? (matches MySchema))

So I can see there is a problem, but I have no indication of which items did not match the schema and which fields didn't match.

matthewgertner avatar Nov 02 '14 13:11 matthewgertner

Since the matches checkers return "data-laden-falsehoods", has has the information to print those messages. Added to trello https://trello.com/c/6p1GLdxg/5-has-etc-should-take-advantage-of-data-laden-falsehoods

marick avatar Nov 28 '14 20:11 marick