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

Your Turn

In this chapter, you’ve learned the major parts of an expectation: the expect method, the subject, to/not_to, and the matcher. You wrote some simple expectations using expect and a few of RSpec’s built-in matchers. You saw how to combine matchers by passing them into one another, and by combining them with and/or.

In the next chapter, we’ll take you on a tour of the matchers that RSpec ships with. But first, test your newfound knowledge of expectations with a quick exercise.

Exercise

We’ve prepared an unfinished spec file that will give you the chance to try out the concepts explained in this chapter. We encourage you to download it, run it, and edit it until you’ve gotten all the specs to pass consistently:

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