Chapter 3. Taking Control of State with Doubles and Hooks
In this chapter, we'll learn how RSpec implements the general testing concepts of stubs, mocks, and spies with
double. We'll start by implementing our own custom mocking method and use it to show off some fun tricks. This will help us understand how mocking works. We'll also appreciate the variety of mocking tools that RSpec offers after we implement one of our own. Then we'll learn how to use RSpec hooks to set up and tear down state related to our tests. Here is what we will cover in this chapter:
- The role of stubs, mocks, and spies in testing
- How to use RSpec's
- Spying on methods and objects with
- Setup and teardown with
A unit in ...