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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.