RSpec Testing
When to Use
- •Writing or editing model, request, feature, or system specs.
- •Adding or changing
describe/context/it/let/subject/before/after.
Workflow
- •Follow the project's RSpec style rules (
.cursor/rules/rspec-style.mdcor CLAUDE.md) for all spec code. - •Use request/controller specs to drive status, redirects, and assigns; keep expectations focused and use
contextfor different params or auth states. - •When adding a new model or feature, create the corresponding spec file under
spec/mirroring theapp/directory structure. - •Run
bundle exec rspec [path]to verify after writing or editing specs.
Spec Types Reference
| Spec type | Directory | Tests |
|---|---|---|
| Model | spec/models/ | Validations, associations, scopes, methods |
| Request | spec/requests/ | HTTP status, response body, redirects |
| System/Feature | spec/system/ | Full browser-driven user flows |
| Helper | spec/helpers/ | View helper methods |
| Mailer | spec/mailers/ | Email delivery and content |
| Job | spec/jobs/ | Active Job behavior |