rspec-testing

Generate and improve RSpec tests for Ruby on Rails applications.

14|Updated Dec 16, 2025
One-click install
npx skills add https://github.com/Shoebtamboli/rails_claude_skills --skill rspec-testing-shoebtamboli
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rspec-testing
Source: https://github.com/Shoebtamboli/rails_claude_skills/tree/main/lib/generators/claude/skills_library/rspec-testing
Command: npx skills add https://github.com/Shoebtamboli/rails_claude_skills --skill rspec-testing-shoebtamboli

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Remove uncertainty and inconsistency when authoring RSpec tests for Rails applications by providing concrete patterns, structure, and examples so tests are readable, reliable, and easy to maintain across teams.

Core Features & Use Cases

  • Opinionated best practices: recommends Arrange-Act-Assert structure, expect syntax, single-responsibility tests, and when to prefer build over create for factories.
  • Decision guidance across test types: explains when to write model, controller, system, component, and service/integration specs and how to choose appropriate scopes and matchers.
  • Practical examples and patterns: includes FactoryBot organization, Capybara system test tips, shared examples, and guidance from Better Specs and thoughtbot for real-world test suites.
  • Use case: convert inconsistent project tests into a consistent suite that validates models, exercises controllers and views, and provides end-to-end system tests for core user flows.

Quick Start

Create or improve an RSpec spec for the Article model that validates title presence, verifies associations, and includes a published? example using the recommended patterns.

Frequently Asked Questions about rspec-testing

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

FAQPage Schema
How do I write RSpec tests for Rails models that follow best practices?

Idiomatic RSpec tests for Rails models follow the Arrange-Act-Assert structure, enforce expect syntax, and maintain single-responsibility per test. They validate associations and attributes using patterns recommended by Better Specs and thoughtbot.

When should I use build vs create with FactoryBot in my Rails test suite?

Use FactoryBot build over create when database persistence is unnecessary for the spec, reducing test suite latency. Decision guidance recommends create only when associations require database records to validate database-level constraints or trigger callbacks.

How do I structure Capybara system tests for Ruby on Rails applications?

Structure Capybara system tests using Arrange-Act-Assert patterns to exercise end-to-end user flows. Generate specs that interact with views and controllers, providing integration coverage for core Rails application workflows.

What is the best way to organize Rails controller specs and service specs?

Organize Rails controller and service specs using single-responsibility tests and appropriate matchers. Apply decision guidance to choose correct test scopes, ensuring specs validate controller responses and service logic without overlapping system tests.

Can I refactor inconsistent Rails test suites into a unified RSpec structure?

Refactor inconsistent Rails test suites into a unified RSpec structure by applying shared examples and opinionated best practices. Convert mixed test styles into readable specs that validate models, exercise controllers, and system test core flows.