testing

Guide Rails testing infrastructure, test types, and best practices.

5|Updated Jan 28, 2026
One-click install
npx skills add https://github.com/ThinkOodle/rails-skills --skill testing-thinkoodle
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: testing
Source: https://github.com/ThinkOodle/rails-skills/tree/main/skills/testing
Command: npx skills add https://github.com/ThinkOodle/rails-skills --skill testing-thinkoodle

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill provides expert guidance on building robust and efficient test suites for Ruby on Rails applications, ensuring code quality and maintainability.

Core Features & Use Cases

  • Test Type Selection: Guides you in choosing the right test type (model, request, system, etc.) for optimal performance and coverage.
  • Test Infrastructure: Covers setup, configuration, and best practices for the Rails testing ecosystem.
  • Use Case: You're unsure whether to write a slow system test or a faster request test for a new feature. This Skill helps you decide based on the need for JavaScript interaction and provides examples for both.

Quick Start

Use the testing skill to understand how to write a system test for a user login flow.

Frequently Asked Questions about testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I choose between Rails system tests and request tests?

Choose Rails request tests for fast endpoint validation, but use system tests when your feature requires JavaScript interaction and Capybara browser simulation. Request tests validate routing and responses, while system tests execute full browser interactions to verify complex UI behavior.

What is the testing pyramid in Rails and why does it matter?

The Rails testing pyramid prioritizes fast model tests at the base, fewer request tests in the middle, and minimal slow system tests at the top. This structure ensures fast, reliable test suites by maximizing rapid isolated unit tests and minimizing expensive browser-driven system tests.

How do I configure Capybara for Rails system tests?

Configure Capybara for Rails system tests by setting up the driven_by method in your application system test case, specifying a browser driver like headless Chrome. This allows your test suite to execute JavaScript-driven interactions and simulate real user behavior across DOM elements.

Does minitest or rspec work better for Rails test suites?

Minitest is Rails' default testing framework, offering fast execution and tight integration, while rspec provides an expressive syntax for readable specifications. Both integrate with Capybara for system tests, so the choice depends on your team's preferred syntax and existing test suite conventions.

How do I set up parallel testing and CI for Rails test suites?

Set up Rails parallel testing by enabling parallelize(workers: :number_of_processors) in your test helper, then configure your CI pipeline to distribute test files across multiple runners. This reduces overall test suite execution time and provides faster CI feedback loops.

What are common Rails testing anti-patterns to avoid?

Common Rails testing anti-patterns include overusing slow system tests for logic that belongs in fast model tests, poorly managing test database state, and avoiding fixtures. Eliminating these issues ensures fast, reliable test suites by maintaining proper test type selection and database isolation.