Install
$ agentstack add skill-shoebtamboli-rails-claude-skills-minitest-testing ✓ scanned · ✓ verified — works with Claude Code, Cursor, and more.
Security review
✓ PassedNo issues found. Passed automated security review. · v0.1.0 How review works →
- ✓ Prompt-injection patterns
- ✓ Secret / credential exfiltration
- ✓ Dangerous shell & filesystem operations
- ✓ Untrusted network calls
- ✓ Known-malicious package signatures
What it can access
- ✓ Network access No
- ✓ Filesystem access No
- ✓ Shell / process execution No
- ✓ Environment & secrets No
- ✓ Dynamic code execution No
From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.
About
Minitest Testing for Rails
Write comprehensive, maintainable Minitest tests following Rails conventions and best practices. This skill provides patterns for model tests, controller tests, system tests with Capybara, and fixture usage.
- Writing new tests for models, controllers, or system workflows
- Reviewing existing test coverage and improving quality
- Fixing failing tests or debugging test issues
- Setting up test fixtures and test helpers
- Writing system tests for end-to-end user workflows
- Testing Hotwire/Turbo behavior in system tests
- Built-in Framework - No additional gems needed, part of Rails
- Fast Execution - Lightweight and performant test suite
- Rails Integration - First-class support in Rails framework
- Fixture Support - Simple YAML-based test data
- System Tests - Built-in Capybara integration for browser testing
- Parallel Testing - Run tests in parallel with
bin/rails test:parallel
Before completing testing work:
- ✅ Tests follow Minitest naming convention:
test "descriptive name" - ✅ Fixtures used appropriately for test data
- ✅ System tests cover critical user workflows
- ✅ Assertions are specific and descriptive
- ✅ Tests are independent and can run in any order
- ✅ All tests passing:
bin/rails test
- Use descriptive test names:
test "creates post with valid attributes" - One assertion concept per test (may use multiple assert calls)
- Use specific assertions:
assert_equal,assert_redirected_to, not justassert - Reference fixtures with symbols:
posts(:published_post) - Use
setupandteardownfor test lifecycle management - Use
assert_differencefor counting changes - System tests for critical workflows, controller/model tests for details
- Run tests before committing code
Core Testing Principles
1. Test Structure
Organize tests with clear phases:
test "creates article with valid attributes" do
# Arrange - set up test data
user = users(:alice)
# Act - perform the action
article = Article.create(
title: "Test Article",
body: "Content here",
user: user
)
# Assert - verify the outcome
assert article.persisted?
assert_equal "Test Article", article.title
end
2. Test Independence
Each test should be independent and able to run in any order. Use setup for common initialization:
class ArticleTest
draft:
user: bob
title: Draft Article
body: Work in progress
status: draft
Using Fixtures in Tests
test "finds published articles" do
published = articles(:published)
draft = articles(:draft)
results = Article.published
assert_includes results, published
assert_not_includes results, draft
end
Test Helpers
Authentication Helper
# test/test_helper.rb
class ActionDispatch::IntegrationTest
def sign_in_as(user)
post login_path, params: { email: user.email, password: "password" }
end
end
Custom Assertions
# test/test_helper.rb
module ActiveSupport
class TestCase
def assert_valid(record)
assert record.valid?, "Expected #{record.class} to be valid, errors: #{record.errors.full_messages}"
end
end
end
Running Tests
# Run all tests
bin/rails test
# Run specific test file
bin/rails test test/models/article_test.rb
# Run specific test by line number
bin/rails test test/models/article_test.rb:12
# Run tests by pattern
bin/rails test test/models/*_test.rb
# Run system tests only
bin/rails test:system
# Run tests in parallel
bin/rails test:parallel
# Run with verbose output
bin/rails test -v
# Run and show coverage
COVERAGE=true bin/rails test
- rails-models - ActiveRecord patterns for database models
- rails-controllers - Controller patterns and RESTful design
- rails-hotwire - Testing Turbo Frames/Streams and Stimulus
- rails-jobs - Testing background jobs with SolidQueue
- rails-mailers - Testing email delivery with ActionMailer
Official Documentation:
- Rails Testing Guide - Comprehensive Rails testing guide
- Minitest Documentation - Minitest framework docs
- Capybara Cheat Sheet - System test selectors
Tools:
- SimpleCov - Code coverage for Ruby
- shoulda-matchers - Additional matchers for Rails
Source & license
This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.
- Author: Shoebtamboli
- Source: Shoebtamboli/railsclaude_skills
- License: MIT
- Homepage: https://rubygems.org/gems/railsclaudeskills
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet — be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.