~/talk

So writing tests feels painful. What now?

Talkat RailsConf 2024 · 2024-05-07..05-09· [testing]
slides:none on file

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

  1. 0:00Introduction
  2. 1:51Testing pain reasons
  3. 3:58Pets Patreon example
  4. 7:52Tests purpose and mindset
  5. 9:59Writing a test step by step
  6. 13:34Debugging test failures
  7. 15:00Taking a break
  8. 16:24Trustworthy tests
  9. 17:29Class responsibilities
  10. 19:13Refactoring tests
  11. 21:42Encapsulating behavior
  12. 23:08Small improvements
  13. 24:12Take action now
  14. 25:39Design patterns
  15. 27:24Next steps
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.