Ensures comprehensive test coverage following Rails testing best practices
Automatically enforces Rails testing best practices when you create or modify tests. It checks for AAA pattern, proper factory usage, coverage thresholds, and detects flaky tests like `sleep()` calls.
/plugin marketplace add nbarthel/claudy/plugin install rails-workflow@claudyThis skill inherits all available tools. When active, it can use any tool Claude has access to.
Automatically ensures test quality and comprehensive coverage.
Automatic Checks:
When It Activates:
Good:
RSpec.describe User do
describe '#full_name' do
it 'combines first and last name' do
# Arrange
user = User.new(first_name: 'John', last_name: 'Doe')
# Act
result = user.full_name
# Assert
expect(result).to eq('John Doe')
end
end
end
Skill Output (if violated):
⚠️ Test Pattern: AAA structure not clear
Location: spec/models/user_spec.rb:15
Recommendation: Separate Arrange, Act, Assert with comments
Detects:
# RSpec
describe Model do
it 'does something' do
expect(value).to eq(expected)
end
end
# Minitest
class ModelTest < ActiveSupport::TestCase
test "does something" do
assert_equal expected, value
end
end
Preferred:
# spec/factories/users.rb
FactoryBot.define do
factory :user do
email { Faker::Internet.email }
name { Faker::Name.name }
end
end
# In tests
user = create(:user)
Skill Output:
ℹ️ Test Pattern: Consider using FactoryBot
Location: spec/models/post_spec.rb:8
Current: User.create(name: 'Test', email: 'test@example.com')
Recommendation: Define factory and use create(:user)
Checks:
Skill Output:
⚠️ Test Coverage: Below threshold
File: app/models/order.rb
Coverage: 65% (threshold: 80%)
Missing: #calculate_total, #apply_discount methods
Add tests for uncovered methods.
Problem:
# BAD
it 'expires after 1 hour' do
user = create(:user)
sleep(3601) # ❌ Actual waiting
expect(user.expired?).to be true
end
# GOOD
it 'expires after 1 hour' do
user = create(:user)
travel 1.hour do # ✅ Time travel
expect(user.expired?).to be true
end
end
Skill Output:
❌ Test Anti-pattern: Using sleep in test
Location: spec/models/session_spec.rb:42
Issue: sleep() makes tests slow and flaky
Fix: Use time helpers
travel 1.hour do
# assertions here
end
Should test:
Example:
RSpec.describe Post, type: :model do
describe 'validations' do
it { should validate_presence_of(:title) }
it { should validate_uniqueness_of(:slug) }
end
describe 'associations' do
it { should belong_to(:user) }
it { should have_many(:comments) }
end
describe '#published?' do
it 'returns true when published_at is set' do
post = build(:post, published_at: 1.day.ago)
expect(post.published?).to be true
end
end
end
Should test:
Example:
RSpec.describe 'Posts API', type: :request do
describe 'GET /api/v1/posts' do
it 'returns all posts' do
create_list(:post, 3)
get '/api/v1/posts'
expect(response).to have_http_status(:ok)
expect(JSON.parse(response.body).size).to eq(3)
end
context 'when not authenticated' do
it 'returns unauthorized' do
get '/api/v1/posts'
expect(response).to have_http_status(:unauthorized)
end
end
end
end
# .rails-testing.yml
coverage:
models: 80
controllers: 70
services: 90
patterns:
enforce_aaa: warning
require_factories: info
detect_flaky: error
framework:
auto_detect: true
prefer: rspec # or minitest
This skill ensures your Rails app has comprehensive, maintainable test coverage.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.