Test Doubles

Learn to use stubs, mocks, spies, and fakes with RSpec.


Simple Stubs

Use rspec-mocks to stub out an object in a test.

Stubs with Constraints

Learn to set constraints on stubbed methods using RSpec.

Setting Expectations with Mocks

Learn to unit test methods with side effects and mutation using mocks.

Verifying Expectations with Spies

Learn how to keep your unit tests tidy with an alternative to mocks: spies.

Testing Flexible Interactions with Fakes

Learn how to test complex or flexible interactions by using fakes.

Verifying Mailers with Test Doubles

Now that you've learned how to use stubs, mocks, spies, and fakes, it's time to pull it all together.