So writing tests feels painful. What now?
summary
Adds a test with RSpec and Factory bot for TierWithTrialUpgrader that exercises a new SubscriptionNotifier.notify_trial_started side effect and hits a Stripe subscription update causing external requests, so the original spec needs multiple stubs and class method stubbing to pass. Rewrites the test from scratch, discovers surprising coupling to Stripe, then refactors by extracting notified_update_with_trial as a seam and moving behavior into a StripeSubscription spec; tests pass and the upgrader now coordinates without leaking API details.
AI-written summary · about
chapters (15)
- 0:00Introduction
- 1:51Testing pain reasons
- 3:58Pets Patreon example
- 7:52Tests purpose and mindset
- 9:59Writing a test step by step
- 13:34Debugging test failures
- 15:00Taking a break
- 16:24Trustworthy tests
- 17:29Class responsibilities
- 19:13Refactoring tests
- 21:42Encapsulating behavior
- 23:08Small improvements
- 24:12Take action now
- 25:39Design patterns
- 27:24Next steps
related talks
29m"Testing. Why so serious?"
27mTDD on the Shoulders of Giants
34mEliminating Inconsistent Test Failures
06mAvoiding Sneaky Testing Antipatterns
54mTDD Workshop: Outward-in Development, Unit Tests, and Fixture Data
09mSpeeding Up Your Test Suite
46mBetter code through boring(er) tests
39mStop Testing, Start Storytelling
