Installing RSpec

First, to use RSpec 3, you need a recent version of Ruby. We’ve tested our examples in this book with Ruby 2.4, and encourage you to use that version for the easiest path. You may get slightly different results on other versions of Ruby. If you’re using something older, go to the Ruby download page and grab a newer one.[9]

RSpec is made of three independent Ruby gems:

  • rspec-core is the overall test harness that runs your specs.

  • rspec-expectations provides a readable, powerful syntax for checking properties of your code.

  • rspec-mocks makes it easy to isolate the code you’re testing from the rest of the system.

You can install these individually and mix them with other test frameworks, assertion libraries, and mocking tools. But ...

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.