nubank / matcher-combinators

Library for creating matcher combinator to compare nested data structures
Other
468 stars 23 forks source link

Common misconception about `equals` not being applied to `map`s #217

Closed gilvan-reis closed 10 months ago

gilvan-reis commented 10 months ago

Context

It is a common misconception from users that the default matcher for map is embeds. We already had another issue that improved the documentation, but this problem continues to happen very often.

In my team, we are creating several replicated functions to do deep-equals (following this README section) to validate nested maps.

This discussion already started in a message in the #matcher-combinator slack channel.

Proposed Solution

Create the deep-equals function in the matcher-combinators.matchers namespace with a proper docstring trying to bring this explanation closer to the code.

(defn deep-equals [expected]
  (match-with [map? m/equals]
              expected))
gilvan-reis commented 10 months ago

Closed by https://github.com/nubank/matcher-combinators/pull/218