rspec-testing-pyramid

Enforce the testing pyramid pattern for Rails RSpec test suites.

21|2|Updated May 24, 2026
One-click install
npx skills add https://github.com/sandeepmvl/rails-skills --skill rspec-testing-pyramid
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rspec-testing-pyramid
Source: https://github.com/sandeepmvl/rails-skills/tree/main/skills/04-rspec-testing-pyramid
Command: npx skills add https://github.com/sandeepmvl/rails-skills --skill rspec-testing-pyramid

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes assets (resource) components.

What problem does it solve?

AI-generated Rails RSpec test suites are often slow, flaky, and ignore team conventions: they overuse system specs, hardcode test data instead of using factories, hit real external APIs, and lack proper setup for parallel testing or coverage tracking, leading to wasted CI time and ignored test failures.

Core Features & Use Cases

  • Testing Pyramid Enforcement: Guides teams to prioritize fast model and request specs over slow system specs, cutting test suite runtime and reducing flakiness.
  • FactoryBot Best Practices: Provides idiomatic patterns for sequences, traits, and associations to create maintainable test data that avoids uniqueness validation failures and brittle setup.
  • Full Tooling Integration: Includes drop-in templates for spec_helper.rb, rails_helper.rb, and .rspec, plus patterns for VCR/WebMock to stub external APIs, Cuprite for fast headless system specs, transactional test database strategies, parallel testing setup, and SimpleCov coverage thresholds.
  • Real-World Use Case: For example, if your team's RSpec suite takes 25 minutes to run and has intermittent flaky system specs, this skill guides you to convert non-JS system specs to request specs, add parallel testing for large suites, and fix N+1 queries that slow down spec execution.

Quick Start

Use the rspec-testing-pyramid skill to refactor your slow, flaky Rails RSpec test suite into a fast, deterministic testing pyramid with proper FactoryBot usage and VCR stubs for external API calls.

Frequently Asked Questions about rspec-testing-pyramid

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

FAQPage Schema
How do I fix a slow and flaky Rails RSpec test suite?

To fix a slow, flaky Rails RSpec test suite, enforce the testing pyramid pattern by converting slow system specs to fast request specs and using FactoryBot for maintainable test data. This reduces CI runtime and eliminates intermittent failures caused by overusing system tests.

How do I stub external API calls in RSpec tests?

Stub external API calls in RSpec tests using VCR and WebMock to prevent network flakiness. This ensures deterministic test execution by recording HTTP interactions and replaying them, avoiding live API dependencies and hard-coded external data.

When should I use system specs versus request specs in Rails?

Use request specs instead of system specs for non-JavaScript interactions to enforce the testing pyramid and maximize RSpec speed. Reserve system specs configured with Cuprite for headless browser flows requiring JavaScript, cutting test suite runtime and flakiness.

How do I avoid uniqueness validation failures with FactoryBot in Rails?

Avoid uniqueness validation failures with FactoryBot by using idiomatic sequences, traits, and associations. This creates maintainable test data that prevents brittle setup and ensures unique records without hardcoding values in your RSpec models.

Can I set up parallel testing and SimpleCov coverage tracking in RSpec?

Yes, you can set up parallel testing and SimpleCov coverage tracking in RSpec using drop-in templates for spec_helper and rails_helper. This optimizes large test suite execution time and enforces coverage thresholds to maintain code quality.

Why are my AI-generated RSpec tests ignoring team conventions?

AI-generated RSpec tests ignore team conventions by overusing system specs, hitting real external APIs, and hardcoding test data. Enforce the testing pyramid pattern with FactoryBot and VCR stubs to align generated tests with standard conventions.