RSpec: The Bad Parts
summary
Claims that RSpec macros are the problem not the language and demonstrates concrete fixes: a real 4,500-line file contains 531 let definitions across 131 method names (78 overridden, some redefined up to 69 times) and 87 subject defs, consuming ~14% of the file; examples come from Ruby on Rails and Mastodon tests. Refactors replace lets with Ruby methods or instance vars and use the inline method refactor, flatten contexts, inline before blocks, and run the suite — tests continue to pass.
AI-written summary · about
chapters (9)
- 0:00Introduction
- 1:45RSpec let and subject
- 3:29Problems with let and subject
- 7:49Refactoring let and subject
- 10:17DRY in test setup
- 13:21Refactoring Rails test
- 17:32Issues with before blocks
- 19:37Shared examples dangers
- 20:41Summary
related talks
01h 00mTesting Heresies
20mApplying RSpec Best Practices
01h 04mClean RSpec: A Workshop on Ruby Testing Craftsmanship
29m"Testing. Why so serious?"
40mRSpec: It's Not Actually Magic
42mWorkshop / Taming Chaotic Specs: RSpec Design Patterns
34mBetter Code Through Boring(er) Tests
39mMiniTest: Refactoring Test Unit and RSpec back to version 0.0.1
