Even on their own, matchers are powerful tools for your tests. But they really shine when you compose them with other matchers to specify exactly what you expect (and nothing more). The result is more robust tests and fewer false failures.
There are a few different ways to compose matchers:
Before we consider these three cases, let’s look at how matchers determine whether or not the subject matches.
Matchers build on top of one of Ruby’s standard protocols in order to provide composability: the humble === method. This method, often called “three-quals” or “case equality,” ...