---
name: 37signals-testing
description: Test Rails apps the 37signals way - Minitest and fixtures only, a deliberate coverage budget (heavy on models and controllers, few system tests, no view or JS unit tests), and fixture patterns from Campfire and Fizzy. Use alongside rails-testing in apps that use Minitest + fixtures, or when the user asks how 37signals tests.
disable-model-invocation: true
---

# 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/models` structure in `test/models`: `app/models/card/closeable.rb` ↔ `test/models/card/closeable_test.rb`; shared concerns under `test/models/concerns/`.
- UUID PKs break fixture ordering: generate deterministic, label-derived UUIDv7s in fixtures so `.first`/`.last` are 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).
