Closed
Description
Say I want to talk to a service to create a pony. We know the response will be:
{
id: 1,
history: [
{ event: "create", date: "01-01-2000", id: 123 },
{ event: "health_check", date: "01-01-2000", id: 124 },
{ event: "verify", date: "01-01-2000", id: 125 },
{ event: "approve", date: "01-01-2000", id: 126 }
]
}
However, I only care IDs of two particular events - create
and approve
.
So my Pact is:
expected_response = {
id: Pact.like(123),
history: [
{
event: 'approve',
id: Pact.like(2)
},
{
event: 'create',
id: Pact.like(1)
}
]
}
Note I don't even care the order within the history
array.
This Pact setup won't work because Pact will try to exact match on history array. And then it will complain about array order and length not match.
The current each_like
method only accepts one element.
I think the ideal scenario will be having a new matcher called array_contains
which allow us to match and generate multiple elements in an array; and ignore array length and order.
Metadata
Metadata
Assignees
Labels
No labels