/superpowers-rails:rails-testing-conventionsfrom superpowers-rails
Guides RSpec test creation in Rails with conventions: request, system, model, policy, component specs; use real data, no mocking, Capybara for UI.
Ships in superpowers-rails. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Tests verify behavior, not implementation. Real data, real objects, pristine output.
| Type | Location | Use For |
|---|---|---|
| Request | spec/requests/ | Single action (CRUD, redirects). Never test auth here |
| System | spec/system/ | Multi-step user flows through the UI. Every action via Capybara (clicks, fills, navigates) |
| Model | spec/models/ | Public interface + Shoulda matchers |
| Policy | spec/policies/ | ALL authorization tests belong here |
| Component | spec/components/ | ViewComponent rendering |
create(:company_user, role: :mentor) not create(:user):published, :draft for variationslet by default - let! only when record must exist before testupdate! in before blocks| Do | Don't |
|---|---|
| Test real behavior | Test mocked behavior |
| WebMock for external APIs | Mock internal classes |
| Explicit factory attributes | Rely on factory defaults |
let by default | let! everywhere |
| Capture expected errors | Let errors pollute output |
| Wait for elements | Use sleep |
| Assert content in index tests | Only check HTTP status |
| Click/fill/navigate in system specs | Replace user actions with model calls |
accept_confirm { click_button } | Skip confirmation dialogs |
sleep in system specs - Use Capybara's waitingrecord.do_thing! + visit result_path is not a system spec. Click the buttonSystem specs test the full user journey through the browser. If a user would click it, the spec clicks it.
NEVER replace UI interactions with direct model calls. Setting up state via code (e.g., record.reserve!(user)) then visiting the result page is a request spec pretending to be a system spec. It skips the UI being tested.
| User does this | Spec does this | NEVER this |
|---|---|---|
| Clicks "Assign to me" | click_button('Assign to me') | record.reserve!(user) |
| Navigates via menu | click_link('Reviews') | visit reviews_path directly |
| Confirms a dialog | accept_confirm { click_button(...) } | Skip the dialog |
| Fills a form | fill_in 'Name', with: 'value' | Record.create!(name: 'value') |
Factory setup (creating the preconditions: users, records, associations) is fine. An initial visit to start the flow is fine. Replacing user actions (navigation, clicks, form fills that the test actually verifies) is not.
If a UI interaction is hard to automate (confirmation dialogs, JS-heavy flows), use Capybara's tools (accept_confirm, accept_alert, execute_script) — don't bypass the UI.
Remember: Tests verify behavior, not implementation.
What SKILL.md sets; muted values are Claude Code's defaults
23 skills in this plugin
/brainstormingYou MUST use this before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements and design before implementation./diagnosing-superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness./dispatching-parallel-agentsUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesnpx claudepluginhub fryga-io/superpowers-rails --plugin superpowers-railsOther plugins' skills for the same job