Appendix 3Matcher Cheat Sheet

In Chapter 11, Matchers Included in RSpec Expectations, we went through the most commonly used matchers included in RSpec. Now, we’d like to show you all the matchers built-in to RSpec as of version 3.6 in a single reference that you can keep handy while you’re writing specs.

The Passes if… column provides an expression for each matcher that’s equivalent to what the matcher checks. The snippet isn’t necessarily how the matcher is implemented internally, as we’ve glossed over a few edge cases that don’t arise during daily use. If you’re curious about these implementation details, you can check out the source code.[134]

Get Effective Testing with RSpec 3 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.