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

Origins: Pure, Partial, and Verifying Doubles

Now that we’ve seen the different usage modes of test doubles, let’s look at where they come from.

Pure Doubles

All of the test doubles you’ve written so far in this chapter are pure doubles: they’re purpose-built by rspec-mocks and consist entirely of behavior you add to them. You can pass them into your project code just as if they were the real thing.

Pure doubles are flexible and easy to get started with. They’re best for testing code where you can pass in dependencies. Unfortunately, real-world projects are not always so tester-friendly, and you’ll need to turn to more powerful techniques.

Partial Doubles

Sometimes, the code you’re testing doesn’t give you an easy way to inject dependencies. ...

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