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

High-Fidelity Fakes

When you work with rspec-mocks, you’re using fake behavior supplied by RSpec. There are other kinds of test doubles, though. You can use an alternative implementation designed to drop into your tests in place of the real thing. Because these mimic the original library’s interface and behavior closely, we call them high-fidelity fakes.

For instance, the FakeFS gem makes it easy to test code that interacts with the filesystem.[109] FakeRedis acts just like the Redis data store but doesn’t require a network connection or a running server.[110] If you use Braintree for credit-card processing, Fake Braintree can stand in during testing.[111]

Sometimes, a library ships with its own high-fidelity fake. The Fog gem, which wraps ...

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