This chapter paved a gradual path into custom matchers. We started off by building custom matchers from RSpec’s existing ones, using helper methods, aliases, and negation. Next, we defined a brand-new matcher using RSpec’s DSL. Finally, we peeled back the curtain and showed that there’s no magic behind matchers. They’re just plain Ruby classes.
With a good set of custom matchers, your specs will become more readable. When there’s a failure, the improved error message will save you time finding the cause.
Now, it’s time to try your hand at writing your own custom matcher.
At the top of the chapter, we looked at some hypothetical matchers for a concert ticketing API. In these exercises, you’re going to implement these matchers. ...