37signals Testing
The opinionated layer on top of rails-testing. Patterns from the Campfire and Fizzy test suites.
Defaults
- Minitest + fixtures. No RSpec, no FactoryBot.
- Tests ship in the same commit/PR as the feature: not before, not later.
Coverage Budget (where 37signals actually spends)
- Heavy: model tests (domain invariants, concerns) and controller/integration tests (full request cycle, auth, formats).
- Light: a few system tests for the critical happy paths (one smoke test can cover signup→use); job tests only for jobs with real logic.
- None: view tests, JS/Stimulus unit tests, exhaustive channel tests. UI behavior is covered indirectly by system tests.
Fixtures
- Express relationships by label, not ID; use ERB for relative timestamps (
created_at: <%= 1.hour.ago %>) and shared computed values (one bcrypt digest reused). - Mirror
app/modelsstructure intest/models:app/models/card/closeable.rb↔test/models/card/closeable_test.rb; shared concerns undertest/models/concerns/. - UUID PKs break fixture ordering: generate deterministic, label-derived UUIDv7s in fixtures so
.first/.lastare stable and runtime records are always newer. - Build rich-content fixtures with production code (
ActionText::Attachment.from_attachable(user).to_html), not hand-written markup.
Red Flags
- Factories or per-test record setup where a fixture would do.
- View tests or Stimulus unit tests (cover the behavior with a system test instead).