machete icon indicating copy to clipboard operation
machete copied to clipboard

Slightly confusing message when string key is mixed up for atom key

Open axelson opened this issue 1 year ago • 3 comments

This assertion (and the reverse) assert %{foo: "bar"} ~> %{"foo" => "bar"} results in an unclear message:

     Assertion with ~> failed

     Mismatches:

       1) .foo: Unexpected key
       2) .foo: Missing key

It's confusing because it looks like the same key is missing, but also unexpected. It might make sense to instead have a custom message in this case, maybe something like .foo: The atom :foo was received, but the string "foo" was expected

axelson avatar Sep 11 '24 04:09 axelson

Yes! This is a confusing one. I think we could implement this pretty tightly in the literal map matcher, doing a bit more set magic here.

Do you want to take a crack at it?

mtrudel avatar Sep 11 '24 14:09 mtrudel

Yeah I'd like to, but no promises on when I'll get around to it. And thank you for the link to that snippet of code to get started.

axelson avatar Sep 11 '24 15:09 axelson

No hurry on my end!

mtrudel avatar Sep 11 '24 20:09 mtrudel