AgentSkillsCN

rspec-testing

按照RSpec风格指南编写并重构RSpec规格:合理安排describe/contexts结构、调整let/subject的顺序、运用共享示例,并在适当情况下坚持“每个示例仅一个断言”。当您需要编写或修改*_spec.rb或spec/**文件时,可使用此功能。

SKILL.md
--- frontmatter
name: rspec-testing
description: Writes and refactors RSpec specs following RSpec style guide: describe/context structure, let/subject order, shared examples, and one-expectation-per-example where appropriate. Use when writing or modifying *_spec.rb or spec/** files.
user-invocable: false

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

  1. Follow the project's RSpec style rules (.cursor/rules/rspec-style.mdc or CLAUDE.md) for all spec code.
  2. Use request/controller specs to drive status, redirects, and assigns; keep expectations focused and use context for different params or auth states.
  3. When adding a new model or feature, create the corresponding spec file under spec/ mirroring the app/ directory structure.
  4. Run bundle exec rspec [path] to verify after writing or editing specs.

Spec Types Reference

Spec typeDirectoryTests
Modelspec/models/Validations, associations, scopes, methods
Requestspec/requests/HTTP status, response body, redirects
System/Featurespec/system/Full browser-driven user flows
Helperspec/helpers/View helper methods
Mailerspec/mailers/Email delivery and content
Jobspec/jobs/Active Job behavior