Closed zbintliff closed 5 years ago
Hey @mefellows been working through this for way longer than I like to admit but i figured out why. Its because we have a EachLike
within a Like
. I assumed it was allowed because in the example you have an EachLIke
within an EachLike
but i guess its is not. If you remove the type matcher on the body
it will work.
Will leave to you if we leave this open or not as I'm not sure what is, or isn't expected behaviour.
I think this is a common confusion, I should fix the examples as the nested *Like
is not necessary, apologies for this (I actually didn't understand this when first creating this library). Perhaps we should not allow this sort of nesting in the DSL itself, or at the very least log a WARN
?
Yeah, it got me good. If we could warn that would be nice.
I can see an argument for both. If I say Like({"a": [], "b":"xx"})
. Should it fail if a
doesn't match length? By definition it should only match type. I could be speaking nonsense cause I've been staring at this for a while though.
I also totally realize that wasn't the intention of LIke
and why they introduced min
and max
and agree its better to be explicit.
I've raised an enhancement issue in pact-support.
@zbintliff if you're game to wade in to the code, you could have a go at a PR. It looks like you've already gotten your hands dirty! It will either be in the writing of the rules here: https://github.com/pact-foundation/pact-support/tree/master/lib/pact/matching_rules/extract.rb or the merging (turning the rules back into Ruby objects) here: https://github.com/pact-foundation/pact-support/tree/master/lib/pact/matching_rules/merge.rb
This turned out to be a fiddly one. Sorry it's taken so long. Please upgrade to v1.54.1 of the standalone @mefellows
Thanks Beth. I've pushed out an update just now.
As an FYI, Pact Go doesn't need direct updates these days (the CLI tools is a separate installation step for users, so they can update independent of Pact Go) - this was to make Pact more idiomatic in the Go ecosystem according to the will of the people. I have updated the minimum version constraints however to ensure people upgrade.
Cool.
Software versions
Expected behaviour
Allow more than one item of the array when
EachLike(x, 1)
is passed. The array provider returns contains two items.Actual behaviour
Fails on verification with
Pact::UnexpectedIndex
errorSteps to reproduce
https://github.com/zbintliff/pact-ruby-standalone-e2e-example/tree/issue/unexpected-index
Relevent log files
Recreatable above