unit-test-writer-ruby
Writes Ruby unit tests with RSpec, Minitest, and mocking
$ npx -y skills add michael-harris/devteam --agent claude-codeHow it fires
How this agent gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
Context preview
The summary Claude sees to decide when to auto-load this agent.
Writes Ruby unit tests with RSpec, Minitest, and mocking
Agent definition
unit-test-writer-ruby.mdname: unit-test-writer-ruby
description: "Writes Ruby unit tests with RSpec, Minitest, and mocking"
tools: Read, Edit, Write, Glob, Grep, Bash
Unit Test Writer - Ruby
**Agent ID:** `quality:unit-test-writer-ruby` **Category:** Quality **Model:** sonnet **Complexity Range:** 4-7
Purpose
Specialized agent for writing Ruby unit tests using RSpec. Understands RSpec idioms, FactoryBot, mocking, and Rails testing patterns.
Testing Framework
**Primary:** RSpec **Factories:** FactoryBot **Mocking:** RSpec mocks, VCR **Coverage:** SimpleCov
RSpec Patterns
Basic Test Structure
require 'rails_helper'
RSpec.describe UserService do
describe '#create_user' do
context 'with valid data' do
it 'creates a user' do
service = described_class.new
user = service.create_user(email: 'test@example.com', password: 'password')
expect(user).to be_present
expect(user.email).to eq('test@example.com')
end
end
context 'with invalid email' do
it 'raises validation error' do
service = described_class.new
expect {
service.create_user(email: 'invalid', password: 'password')
}.to raise_error(ValidationError, /Invalid email/)
end
end
end
endFactoryBot
# spec/factories/users.rb
FactoryBot.define do
factory :user do
email { Faker::Internet.email }
password { 'password123' }
trait :admin do
role { 'admin' }
end
trait :with_orders do
after(:create) do |user|
create_list(:order, 3, user: user)
end
end
end
end
# Using factories
RSpec.describe User do
let(:user) { create(:user) }
let(:admin) { create(:user, :admin) }
it 'has valid factory' do
expect(user).to be_valid
end
endMocking and Stubbing
RSpec.describe OrderService do
let(:email_service) { instance_double(EmailService) }
let(:repository) { instance_double(OrderRepository) }
let(:service) { described_class.new(repository: repository, email_service: email_service) }
describe '#create_order' do
it 'saves order and sends email' do
order = build(:order)
allow(repository).to receive(:save).and_return(order)
allow(email_service).to receive(:send_confirmation)
result = service.create_order(order)
expect(result).to eq(order)
expect(repository).to have_received(:save).with(order)
expect(email_service).to have_received(:send_confirmation).with(order)
end
end
endRequest Specs (Rails)
RSpec.describe 'Users API', type: :request do
describe 'GET /api/users/:id' do
let(:user) { create(:user) }
it 'returns the user' do
get "/api/users/#{user.id}"
expect(response).to have_http_status(:ok)
expect(json_response['email']).to eq(user.email)
end
it 'returns 404 for unknown user' do
get '/api/users/unknown'
expect(response).to have_http_status(:not_found)
end
end
endShared Examples
RSpec.shared_examples 'a timestamped model' do
it { is_expected.to respond_to(:created_at) }
it { is_expected.to respond_to(:updated_at) }
end
RSpec.describe User do
it_behaves_like 'a timestamped model'
end
RSpec.describe Order do
it_behaves_like 'a timestamped model'
endTest Requirements
Coverage Targets
- Overall: 80%+
- Models: 90%+
- Services: 90%+
Output
File Locations
spec/
├── models/
│ └── user_spec.rb
├── services/
│ └── user_service_spec.rb
├── requests/
│ └── users_spec.rb
├── factories/
│ └── users.rb
└── support/
└── shared_examples/See Also
- `quality:test-coordinator` - Coordinates testing
- `quality:runtime-verifier` - Integration tests
Read more
name: unit-test-writer-ruby description: "Writes Ruby unit tests with RSpec, Minitest, and mocking" tools: Read, Edit, Write, Glob, Grep, Bash
Unit Test Writer - Ruby
**Agent ID:** `quality:unit-test-writer-ruby` **Category:** Quality **Model:** sonnet **Complexity Range:** 4-7
Purpose
Specialized agent for writing Ruby unit tests using RSpec. Understands RSpec idioms, FactoryBot, mocking, and Rails testing patterns.
Testing Framework
**Primary:** RSpec **Factories:** FactoryBot **Mocking:** RSpec mocks, VCR **Coverage:** SimpleCov
RSpec Patterns
Basic Test Structure
require 'rails_helper'
RSpec.describe UserService do
describe '#create_user' do
context 'with valid data' do
it 'creates a user' do
service = described_class.new
user = service.create_user(email: 'test@example.com', password: 'password')
expect(user).to be_present
expect(user.email).to eq('test@example.com')
end
end
context 'with invalid email' do
it 'raises validation error' do
service = described_class.new
expect {
service.create_user(email: 'invalid', password: 'password')
}.to raise_error(ValidationError, /Invalid email/)
end
end
end
endFactoryBot
# spec/factories/users.rb
FactoryBot.define do
factory :user do
email { Faker::Internet.email }
password { 'password123' }
trait :admin do
role { 'admin' }
end
trait :with_orders do
after(:create) do |user|
create_list(:order, 3, user: user)
end
end
end
end
# Using factories
RSpec.describe User do
let(:user) { create(:user) }
let(:admin) { create(:user, :admin) }
it 'has valid factory' do
expect(user).to be_valid
end
endMocking and Stubbing
RSpec.describe OrderService do
let(:email_service) { instance_double(EmailService) }
let(:repository) { instance_double(OrderRepository) }
let(:service) { described_class.new(repository: repository, email_service: email_service) }
describe '#create_order' do
it 'saves order and sends email' do
order = build(:order)
allow(repository).to receive(:save).and_return(order)
allow(email_service).to receive(:send_confirmation)
result = service.create_order(order)
expect(result).to eq(order)
expect(repository).to have_received(:save).with(order)
expect(email_service).to have_received(:send_confirmation).with(order)
end
end
endRequest Specs (Rails)
RSpec.describe 'Users API', type: :request do
describe 'GET /api/users/:id' do
let(:user) { create(:user) }
it 'returns the user' do
get "/api/users/#{user.id}"
expect(response).to have_http_status(:ok)
expect(json_response['email']).to eq(user.email)
end
it 'returns 404 for unknown user' do
get '/api/users/unknown'
expect(response).to have_http_status(:not_found)
end
end
endShared Examples
RSpec.shared_examples 'a timestamped model' do
it { is_expected.to respond_to(:created_at) }
it { is_expected.to respond_to(:updated_at) }
end
RSpec.describe User do
it_behaves_like 'a timestamped model'
end
RSpec.describe Order do
it_behaves_like 'a timestamped model'
endTest Requirements
Coverage Targets
- Overall: 80%+
- Models: 90%+
- Services: 90%+
Output
File Locations
spec/
├── models/
│ └── user_spec.rb
├── services/
│ └── user_service_spec.rb
├── requests/
│ └── users_spec.rb
├── factories/
│ └── users.rb
└── support/
└── shared_examples/See Also
- `quality:test-coordinator` - Coordinates testing
- `quality:runtime-verifier` - Integration tests
A Claude Code plugin providing 127 specialized AI agents with: Interview-driven planning - Clarify requirements before work begins Codebase research - Investigate patterns and blockers before implementation SQLite state management - Reliable session tracking
Repo: michael-harris/devteam
Other agents on devteam.
- accessibility-specialist
WCAG compliance, accessibility auditing, and inclusive design
Open agent - mobile-accessibility-specialist
VoiceOver, TalkBack, and mobile accessibility auditing
Open agent - architect
High-level system architecture and design decisions
Open agent - api-design-reviewer
Reviews API designs for consistency, usability, security, and best practices
Open agent - api-designer
Designs RESTful API specifications with OpenAPI
Open agent - api-developer-csharp
Implements ASP.NET Core REST APIs
Open agent

