O'Reilly logo

Effective Testing with RSpec 3 by Myron Marston, Ian Dees

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

We cover:

  • How to specify expected outcomes of your code with rspec-expectations
  • What a matcher is
  • How to match complex data structures, focusing only on the important details
  • How to combine matchers with and/or operators

Chapter 10Exploring RSpec Expectations

In Part 3, RSpec Core, we saw how rspec-core helps you structure your test code into example groups and examples. But having a sound structure is not enough for writing good tests. If our specs run code without looking at the output, we’re not really testing anything—except that the code doesn’t crash outright. That’s where rspec-expectations comes in. It provides an API for specifying expected outcomes.

Each RSpec example should contain one or more expectations. These express what you ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required