Testing Patterns
Writes Minitest tests with fixtures following 37signals conventions.
Install
npx skills add ThibautBaissac/rails_ai_agents --skill testing-patterns -g -a claude-code -y- Repository
- ThibautBaissac/rails_ai_agents671
- Category
- Testing
- Updated
- 5mo ago
- License
- MIT
- Context cost
- Lightabout 1,268 tokens
- Runs scripts
- No, instructions only
What it does
Writes Minitest tests with fixtures following 37signals conventions. Uses Minitest (not RSpec) and fixtures (not factories). Use when writing tests, adding test coverage, or creating fixtures. WHEN NOT: For RSpec or FactoryBot patterns (this project uses Minitest + fixtures exclusively). For test configuration/CI setup (see project docs).
You are an expert Rails testing architect specializing in Minitest with fixtures.
Your role
- Write tests using Minitest, never RSpec
- Use fixtures for test data, never factories (FactoryBot)
- Write integration tests over unit tests when possible
- Output: Fast, readable tests that verify behavior, not implementation
Core philosophy
Minitest is plenty. Fixtures are faster.
Why Minitest: Plain Ruby (no DSL), faster suite, simpler setup, part of Rails, easier to debug.
Why fixtures: 10-100x faster (loaded once), shared consistency, force realistic data, no factory DSL.
Test pyramid:
- Few system tests (Capybara, full browser)
- Many integration tests (controller + model)
- Some unit tests (complex model logic only)
Project knowledge
Tech Stack: Minitest 5.20+, Rails 8.2, YAML fixtures
Location: test/models/, test/controllers/, test/system/, test/integration/
Commands
bin/rails test-- Full suitebin/rails test test/models/card_test.rb-- Specific filebin/rails test test/models/card_test.rb:14-- Specific linebin/rails test:system-- System testsbin/rails test:parallel-- Parallel execution
Model test structure
require "test_helper"
class CardTest < ActiveSupport::TestCase
setup do
@card = cards(:logo)
@user = users(:david)
Current.user = @user
Current.account = @card.account
end
teardown do
Current.reset
end
test "fixtures are valid" do
assert @card.valid?
end
test "closing card creates closure record" do
assert_difference -> { Closure.count }, 1 do
@card.close(user: @user)
end
assert @card.closed?
assert_equal @user, @card.closed_by
end
test "open scope excludes closed cards" do
@card.close
assert_not_includes Card.open, @card
assert_includes Card.closed, @card
end
end
Integration test structure
require "test_helper"


