mtrudel / machete

Literate test matchers for ExUnit
MIT License
56 stars 1 forks source link

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

Open axelson opened 2 weeks ago

axelson commented 2 weeks ago

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

mtrudel commented 2 weeks ago

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?

axelson commented 2 weeks ago

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.

mtrudel commented 2 weeks ago

No hurry on my end!