- Courses
- TDD and BDD in Ruby
- Day 3 - Advanced RSpec and Faking
Lesson 10 of 16
Lab: Mock Objects
Text lesson
Please download included attachment.
Downloads
- mocks-lab.pdf (PDF, 104 KB)
Related
- A simple handwritten mock example (external link, opens in new tab) · The Art of Unit Testing, 2nd ed., ch. 4
The 2nd edition's handwritten mock example; the lab's first exercise also uses only hand-written mocks, for a string calculator that notifies a slow logger.
- Using a mock and a stub together (external link, opens in new tab) · The Art of Unit Testing, 2nd ed., ch. 4
Section on using a mock and a stub together, as in the lab's failed-logging scenarios, where the logger raises an error and the web service must be notified.
- Defining isolation frameworks (external link, opens in new tab) · The Art of Unit Testing, 3rd ed., ch. 5
Section defining isolation frameworks; the lab's later exercises repeat the work with Bogus instead of hand-written mocks.