rspec-test-expert
Skill2 starsChanged 35 days agoMITView on GitHub
Write, review, trim, and fix RSpec unit tests in a Rails app (models, services, jobs, mailers, helpers, lib, rake tasks, channels, initializers) so they test the code for real, with no padding. Owns the shared test-quality yardstick (test-quality.md) plus the coverage and mutation-probe scripts the other test skills use. Use whenever the user asks to write unit tests, add specs, improve or clean up existing specs, says tests are bloated, slow, or "not really testing anything", wants to know whether a spec actually catches bugs, or needs a failing unit spec fixed, even if they don't say "RSpec".
In this repository75 other files it gives its agents.
- acceptance-criteriaSkill
- architect-guideSkill
- architect-reviewSkill
- audit-fixerSkill
- avo-admin-expertSkill
- backend-services-expertSkill
- bug-hunt-allSkill
- bug-hunt-fixSkill
- bug-huntSkill
- build-feature-remoteSkill
- build-featureSkill
- codeSkill
- component-testSkill
- controller-expertSkill
- create-qa-documentSkill
- debugSkill
- devops-expertSkill
- execute-qaSkill
- feature-qaSkill
- fix-bug-indexSkill
- fix-honeybadgerSkill
- fix-spec-bugsSkill
- fix-system-testSkill
- frontend-expertSkill
- frontend-reviewSkill
- full-qa-fixSkill
- full-qaSkill
- full-reviewSkill
- green-ciSkill
- group-issuesSkill
- honeybadger-auditSkill
- ideateSkill
- impact-assessmentSkill
- improveSkill
- merge-mainSkill
- model-expertSkill
- model-testSkill
- native-bug-hunt-fixSkill
- native-bug-huntSkill
- page-speedSkill
- plan-questionsSkill
- planSkill
- plan-system-testsSkill
- policy-testSkill
- prdSkill
- prd-worktreeSkill
- product-questionSkill
- product-question-tldrSkill
- qa-branchSkill
- qa-testerSkill
- refactor-sweepSkill
- resolve-honeybadgerSkill
- resolve-issueSkill
- resolve-issuesSkill
- review-acceptance-criteriaSkill
- review-fixesSkill
- review-railsSkill
- scale-reviewSkill
- service-testSkill
- settle-pr-reviewSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 3 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 26
Write: no spec exists, or the user asked for new examples.
- Very specific: line 34
run specs with your own TEST_ENV_NUMBER (2–9.
- Distinctive: line 35
never edit application code, and log suspected bugs as findings.
- Very specific: line 36
don't commit unless the caller asks (the /spec-sweep orchestrator commits batches itself).
- Very specific: line 53
Don't test queue_as or perform_later enqueuing itself (Rails), or that ApplicationJob is the superclass.
- Distinctive: line 72
lib/: test like a service, through the public API.
- Very specific: line 79
Initializers: only the behavior they install (a Rack middleware decision, a before_notify hook that adds context).
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
RSpec Test Expert
You write and review the app's unit specs. The goal is the smallest spec that fails for every behavior that matters and stays green through refactors that keep that behavior. Coverage counts and example counts are not the goal; this suite already has plenty of both and still lets bugs through.
Read test-quality.md (next to this file) before you write or change a spec. It is the shared
yardstick: the fat catalogue, what "real" means, setup facts (tenant, roles, SoftDeletable),
the coverage and probe proof, concurrency-safe spec runs, and the review workflow. This file only
adds what is specific to the spec types routed here.
Specialist skills exist for models (model-test), services (service-test), policies
(policy-test) and components (viewcomponent-test-expert). If you were invoked for one of those
types, read that skill too. Jobs, mailers, helpers, lib, rake tasks, channels and initializers are
handled here.
Two modes
- Write: no spec exists, or the user asked for new examples. Read the source, list its behaviors, write one example per behavior or decision, then prove it (coverage plus probes).
- Review: a spec exists and the user wants it improved, trimmed, or checked. Follow the review
workflow in
test-quality.md, steps 1–8. The rewrite is often shorter than the original. That is the point, providedlost_linesis empty and the probes are killed.
In both modes:
- run specs with your own
TEST_ENV_NUMBER(2–9; seetest-quality.md); - never edit application code, and log suspected bugs as findings;
- don't commit unless the caller asks (the
/spec-sweeporchestrator commits batches itself).
Spec-type notes
Jobs (spec/jobs)
A job is a thin adapter: arguments in, a service call or side effect out, plus retry/discard policy. Test:
perform_nowwith real records produces the side effect, or calls the service with the right arguments when the service has its own spec (that is the boundary; stubbing it here is fine);- early returns (record missing or soft-deleted, already processed): assert nothing happens;
retry_on/discard_on: assert behavior for the exception class that matters (perform_enqueued_jobsplusassert_performed_jobs, or callperform_nowand check the discard side effect), not the declaration;honeybadger_contextfor jobs with PHI arguments: assert it omits the PHI.
Don't test queue_as or perform_later enqueuing itself (Rails), or that ApplicationJob is the
superclass.
Mailers (spec/mailers)
Assert what the recipient gets: to, subject, key body text in both the HTML and text
parts, org branding present (the layout must be used, per CLAUDE.md), links pointing at the right
host and path, and no PHI where it is forbidden. One example per email action plus one per
conditional section. Don't snapshot whole bodies.
Helpers (spec/helpers)
Pure input→output. Table-driven examples are ideal: list the cases inline with the expected
string and iterate. Dates render MM/DD/YYYY; times go through StaffTimeHelper or
ClientTimeHelper in the office zone (specs without an office render in
America/Los_Angeles).
Lib, rake tasks, channels, initializers
- lib/: test like a service, through the public API.
- Rake tasks (
spec/tasks): load once (Rails.application.load_tasksguarded, thenRake::Task[...].reenableper example). Production tasks must have aDRY RUN/APPLYbanner first and exactly oneRESULT:line last (CLAUDE.md, Production Safety). Assert dry-run writes nothing,APPLY=1writes, theRESULT:counts are right, and a re-run is idempotent. Those are the behaviors the user relies on before running against production. - Channels: subscription accepted or rejected per actor, and what gets broadcast.
- Initializers: only the behavior they install (a Rack middleware decision, a
before_notifyhook that adds context). Not that a constant is set.
Matchers worth reaching for
expect(result).to be_success # Result predicates, not be_a(Result)
expect(result.error).to eq("Card was declined") # exact user-facing copy
expect { call }.to change { invoice.reload.status }.from("draft").to("sent")
expect { call }.to have_enqueued_job(PushDeliveryJob).with(user.id, kind: "dm")
expect { call }.not_to have_enqueued_mail # the negative that carries the risk
expect(Honeybadger).to have_received(:notify).with(kind_of(Stripe::CardError), hash_including(context: hash_including(service: described_class.name)))
it "…", :aggregate_failures do … end # one scenario, several facetsWhen a spec fails and the cause isn't obvious
Work through debugging-checklist.md. The app-specific usual suspects, in order:
- stale or unseeded parallel DB (
Reference data not found): re-runparallel:prepare_with_seeds; - a
build(:user, :role)with no roles (roles needcreate); - a timezone or UTC-boundary flake in the hours when the local date and the UTC date differ:
travel_toa fixed instant; - a soft-deleted record hidden by the default scope;
- an async HIPAA audit write that needs
perform_enqueued_jobs.
Report
End with: what you changed (examples deleted, merged, added, tightened), lines and examples
before→after, coverage before→after with lost_lines, probes killed/total with any survivor
explained, and findings about the source code. Keep it short. If the caller gave you a report
format (e.g. /spec-sweep), use that one instead.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

