An Introduction to Spies in RSpec
summary
Spies in RSpec record method calls so tests assert interactions after actions rather than before, using spy method handles and matchers like have_received and exactly(4).times. A small counter client proving HTTP counts is built and shown first with slow integration tests then refactored to accept an injected http client so doubles, mocks and finally a spy verify get requests without monkeypatching lhttp. Tests pass and runtime drops when network calls are removed.
AI-written summary · about
chapters (6)
- 0:00Start
- 8:02Integrated Test
- 9:08Isolated Test
- 10:24Coupling
- 15:44Live Coding
- 26:05Fixing the Implementation








