This skill guides writing comprehensive Minitest tests for Ruby and Rails applications. Use when creating test files, writing test cases, or testing new features. Covers both traditional and spec styles, fixtures, mocking, and Rails integration testing patterns.
View on GitHubmajesticlabs-dev/majestic-marketplace
majestic-rails
January 24, 2026
Select agents to install to:
npx add-skill https://github.com/majesticlabs-dev/majestic-marketplace/blob/main/plugins/majestic-rails/skills/minitest-coder/SKILL.md -a claude-code --skill minitest-coderInstallation paths:
.claude/skills/minitest-coder/# Minitest Coder
## Core Philosophy
- **AAA Pattern**: Arrange-Act-Assert structure for clarity
- **Behavior over Implementation**: Test what code does, not how
- **Isolation**: Tests should be independent
- **Descriptive Names**: Clear test descriptions
- **Coverage**: Test happy paths AND edge cases
- **Fast Tests**: Minimize database operations
- **Fixtures**: Use fixtures for test data
## Minitest Styles
| Style | Best For | Syntax |
|-------|----------|--------|
| Traditional | Simple unit tests | `test "description"` |
| Spec | Complex scenarios with contexts | `describe`/`it` with `let`/`subject` |
### Traditional Style
```ruby
class UserTest < ActiveSupport::TestCase
test "validates presence of name" do
user = User.new
assert_not user.valid?
assert_includes user.errors[:name], "can't be blank"
end
end
```
### Spec Style
```ruby
class UserTest < ActiveSupport::TestCase
describe "#full_name" do
subject { user.full_name }
let(:user) { User.new(first_name: "Buffy", last_name:) }
describe "with last name" do
let(:last_name) { "Summers" }
it "returns full name" do
assert_equal "Buffy Summers", subject
end
end
end
end
```
## Test Organization
### File Structure
```
test/
├── models/ # Model unit tests
├── services/ # Service object tests
├── integration/ # Full-stack tests
├── mailers/ # Mailer tests
├── jobs/ # Background job tests
├── fixtures/ # Test data
└── test_helper.rb # Configuration
```
### Naming Conventions
- Mirror app structure: `app/models/user.rb` → `test/models/user_test.rb`
- Use fully qualified namespace: `class Users::ProfileServiceTest`
- **Don't add** `require 'test_helper'` (auto-imported)
## Spec Style Patterns
See [resources/spec-patterns.md](resources/spec-patterns.md) for detailed examples.
| Pattern | Use Case |
|---------|----------|
| `subject { ... }` | Method under test |
| `let(:name) { ... }` | Lazy