Your Turn

In this chapter, we discussed the differences between stubs, mocks, spies, and null objects. In particular, you saw how they deal with the following situations:

  • Receiving expected messages
  • Receiving unexpected messages
  • Not receiving expected messages

We also looked at the different ways to create test doubles. Pure doubles are entirely fake, whereas partial doubles are real Ruby objects that have fake behavior added. Verifying doubles fall in between, and have the advantages of both with few of the downsides of either. They’re the ones we use most often.

Now that you understand test doubles, you’ll be ready to tackle the next chapter, where you’ll configure how and when your doubles respond to messages. But first, we have a simple exercise ...

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.