rails-testing-patterns

rails-testing-patterns is a skill for Claude Code from ag0os/rails-dev-plugin. It costs 76 tokens per session (1,049 once invoked), scanned A, original, MIT.

A guide to testing Ruby on Rails applications with RSpec or Minitest. It explains which tests to use for models, API requests, multi-step workflows, emails, background jobs, and important user journeys.

In plain words
What is it for?
Use it when writing or reviewing Rails tests, choosing between unit, request, integration, and system tests, setting up factories or fixtures, or testing jobs and emails.
Why use it?
It helps choose tests that provide useful coverage without making the test suite unnecessarily slow or fragile. It also supports reviewing coverage, fixing flaky tests, and improving test data.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

Part of the rails-dev-plugin plugin — 19 skills, 11 agents shipped together

Good fit Use it when writing or reviewing Rails tests, choosing between unit, request, integration, and system tests, setting up factories or fixtures, or testing jobs and emails.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/ag0os/rails-dev-plugin/rails-testing-patterns
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add ag0os/rails-dev-plugin --skill rails-testing-patterns
Clone the repo
git clone --depth 1 https://github.com/ag0os/rails-dev-plugin

Made for: Claude Code.

Or install rails-dev-plugin, the plugin that ships this one along with the rest of its 19 skills, 11 agents.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for rails-testing-patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/ag0os/rails-dev-plugin/rails-testing-patterns/github.svg)](https://agentmods.dev/skills/ag0os/rails-dev-plugin/rails-testing-patterns)
Your own site
<a href="https://agentmods.dev/skills/ag0os/rails-dev-plugin/rails-testing-patterns"><img src="https://agentmods.dev/badge/skills/ag0os/rails-dev-plugin/rails-testing-patterns/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for rails-testing-patterns

Your own site · 80×15
<a href="https://agentmods.dev/skills/ag0os/rails-dev-plugin/rails-testing-patterns"><img src="https://agentmods.dev/badge/skills/ag0os/rails-dev-plugin/rails-testing-patterns.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 76 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,049 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00076 $0.01049
Opus 5.5 $0.00030 $0.00420
Sonnet 5.5 $0.00015 $0.00210
Haiku 4.5 $0.00008 $0.00105

Measured 1mo ago against content hash 6c0fececfe3d, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

rails-testing-patterns scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/rails-testing-patterns/SKILL.md · 88 lines

How it starts

The opening of the file, as written. The whole thing — 88 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Rails Testing Patterns

Use standard RSpec and Minitest conventions for syntax, assertions, matchers, and Capybara DSL. This skill focuses on opinionated choices — what to test, which framework to use, and how to structure test data.

See patterns.md for decision guidance and non-obvious patterns.

Test Type Decision Matrix

Test Type When to Write Speed ROI Notes
Unit (Model) Business logic, validations, scopes, custom methods Fast Highest ROI — write first wherever models or services carry non-trivial logic
Request API endpoints, auth flows, param handling Medium Highest ROI on the api delivery axis; prefer over controller specs in RSpec
Integration Multi-step workflows spanning controllers Medium Valuable on the html delivery axis — exercises the full request/render cycle
System Critical user journeys only (sign-up, checkout, onboarding) Slow Limit to 10-20 per app; never test CRUD forms with system tests
Mailer Non-trivial email content, conditional delivery Fast Skip if mailer is just a default scaffold
Job Idempotency, retry behavior, side effects Fast Always test jobs that touch external services

Framework, Data, and Directory

Test framework, data strategy, and directory are orthogonal project facts, not architecture choices. A project with extracted service objects can use Minitest; an omakase app can use RSpec. Read them from the project-conventions fingerprint (Testing category) — framework (Minitest/RSpec), data (fixtures/factories), directory (test/ vs spec/). Never infer the framework from architecture.

Test emphasis does vary by Axis B — delivery:

Delivery First tests to write System tests
html Integration tests for key flows Yes, for critical user journeys
api Request specs No — request specs cover it

Anti-Patterns

Read the full file on GitHub · 88 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 88 lines · 76 tokens per session scan A 6c0fececfe3d

Subscribe to this mod's changes

rails-testing-patterns is a skill published in the GitHub repository ag0os/rails-dev-plugin (5 stars, last pushed 4mo ago), licensed MIT. It adds 76 tokens to every session and 1,049 once invoked, about $0.0003 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

rspec-conventions

Rootstrap RSpec conventions. Use when writing, reviewing, or editing RSpec test files (spec//spec.rb, spec/railshelper.rb, spec/spechelper.rb, spec/support//.rb) or factories. Covers describe/context structure, let/subject, matchers, factories, mocking/stubbing, shared examples, and spec types (model, request…

rootstrap/rails_api_base · 82 tokens

testunit-skill

Generates Test::Unit tests in Ruby. Classic xUnit-style testing with assert methods and test case classes. Use when user mentions "Test::Unit", "assertequal Ruby", "Ruby test-unit". Triggers on: "Test::Unit", "Ruby test-unit", "assertequal Ruby" (not RSpec).

LambdaTest/agent-skills · 70 tokens

rspec

RSpec testing best practices for Ruby and Rails applications, covering test organization, data management, and isolation patterns.

Mindrally/skills · 24 tokens

ruby

Ruby development guidelines covering idiomatic code style, Ruby 3.x features, testing with RSpec, and best practices for building maintainable Ruby applications.

Mindrally/skills · 32 tokens

ruby-rails

Use this skill when building Ruby on Rails applications — MVC, ActiveRecord, service objects, API mode, background jobs, and testing. This skill enforces: thin controllers, service objects for business logic, ActiveRecord query best practices, Rails API mode conventions, and RSpec testing patterns. Requires Rails 7+…

j4flmao/agent-skills · 94 tokens

test-service

Use when writing RSpec for a service object under spec/services/. Test the public .call contract. Trigger words: service spec, test service object, spec/services.

igmarin/rails-agent-skills · 36 tokens