RSpec Rails

Guide RSpec testing of Rails models, controllers, system tests, and mailers.

3|Updated Jan 9, 2026
One-click install
npx skills add https://github.com/bastos/ruby-plugin-marketplace --skill rspec-rails-bastos
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: RSpec Rails
Source: https://github.com/bastos/ruby-plugin-marketplace/tree/main/plugins/rspec/skills/rspec-rails
Command: npx skills add https://github.com/bastos/ruby-plugin-marketplace --skill rspec-rails-bastos

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Rails apps require disciplined, consistent testing practices; this skill guides you in applying RSpec effectively across models, controllers and requests, system tests, and mailers, reducing debugging time and improving reliability.

Core Features & Use Cases

  • Clear guidance on available RSpec spec types (Model, Request/Controller, System, Mailer, Job, View, Helper, Routing) and their ideal locations.
  • Practical examples and conventions for structuring specs in a Rails project and common workflows.
  • Real-world use cases illustrating how to test validations, endpoints, UI flows, and mailers with RSpec.

Quick Start

Follow the examples to boot a Rails spec suite by creating a sample model spec in spec/models and a request spec in spec/requests, then run rspec.

Frequently Asked Questions about RSpec Rails

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

FAQPage Schema
What is the difference between model and request specs in Rails testing?

System specs in RSpec cover end-to-end UI flows within a Rails application, simulating real user interactions to verify that the entire stack, from routing to interface rendering, functions correctly together.

What's the best way to test Rails controller actions with RSpec?

Testing mailers with RSpec in Rails involves creating spec files under spec/mailers to verify email rendering and delivery actions, ensuring that mailer workflows function correctly across the application stack.

Do I need RSpec to test validations in a Rails model?

Testing Rails controller actions is best achieved using request specs in spec/requests, which validate routing and endpoint responses to ensure controller actions behave reliably and maintainably.

How do I structure RSpec specs for a Rails application?

You need RSpec to test validations in a Rails model by creating focused specs in spec/models, which validate model behaviors and rules to reduce debugging time and improve application reliability.

Why does my Rails test suite lack maintainability?

Rails test suites lack maintainability when RSpec conventions for file locations and spec types are not enforced, leading to disorganized spec/ directories and inconsistent testing practices across models and controllers.