cook....@gmail.com wrote:
> Incidentally, it would be even better if I didn't have to use contains -
> just being able to put "anything" in my expected value at any level
> would be ideal.
I think it's a step too far to treat the right-hand side of an arrow as
meaning "contains":
(fact [1 2 3 4] => [1 2 3]) ; passes?
I think you'd want to write this:
(fact [1 2 3 4] => (contains [1 2 3]))
That leaves the question of what this should mean:
(fact (f) => [1 even? 3])
Should it match [1 2 3]? Or specifically a collection with a function:
[1 even? 3]?
I think the evidence is that people will typically expect [1 2 3] to
pass the test. For example, I had to change prerequisite arglist
matching to work that way because people (including me) kept expecting this:
(fact
(f) => 3
(provided
(g even?) => 1))
... to have `(g even?)` match `(g 2)`.
This is a potentially breaking change, so it would have to go in Midje
2.0. However, I doubt it would actually break any test I've ever written
for production code.
On the other hand, the `just` checker does support `:in-any-order` and
`:gaps-ok` qualifiers. It's a bit jarring that `just` is required for
those cases but not for the more common case.
(fact [1 2 3] => [1 even? odd?]
(fact [1 2 3] => (just [1 even? odd?] :in-any-order)
I have used `:in-any-order` a fair amount. However: `just` with no
qualifiers could just be a more verbose way of writing the default.
Upshot: I think this should work as you expect:
> (f) => (contains {:order {:payment {:timestamp anything :amount 100}}})
... and this should probably also work to mean an exact match:
>> (f) => {:order {:payment {:timestamp anything :amount 100}})