Practice ยท 2 of 2
The interaction contract
Implement MailerSpy and send_welcome(mailer, user):
- MailerSpy: send(to, subject, body) records the call and returns True; if fail_next is set, it raises ConnectionError once (and clears the flag) instead
- send_welcome: sends ('Welcome!', 'Hi <name>') to user['email']; returns True on success, False when the mailer raised ConnectionError โ and on failure it must NOT retry inside the call
The spy makes the contract observable: exactly one send on success, exactly zero on failure.
Difficulty: advanced
Press Submit to check your solution.
Back to lesson: Practice: Deterministic Doubles