rspec

Write and review Ruby/Rails RSpec specs following the RSpec Style Guide and Better Specs.

Updated Jan 28, 2026
One-click install
npx skills add https://github.com/shubhamtaywade82/trading_playground --skill rspec-shubhamtaywade82
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rspec
Source: https://github.com/shubhamtaywade82/trading_playground/tree/main/.cursor/skills/ruby/rspec
Command: npx skills add https://github.com/shubhamtaywade82/trading_playground --skill rspec-shubhamtaywade82

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill helps Ruby and Rails teams produce clean, consistent, and maintainable RSpec tests by following established style guides (RSpec Style Guide) and Better Specs.

Core Features & Use Cases

  • Guided test structure: Provides best practices for organizing describe/context/it blocks, including spacing and grouping of subject/let/before blocks.
  • Let and subject guidance: Encourages using let/let! and named subjects appropriately to improve readability and test reliability.
  • Matcher & doubles guidance: Promotes use of predicate matchers, strong expectations, and verified doubles to make tests robust.
  • Use Cases: Applies to unit specs for models/controllers, request specs, and integration tests in Ruby/Rails projects.

Quick Start

Read the RSpec Style Guide and Better Specs, then start applying the patterns to your existing specs. Begin by aligning the top-level describe/context blocks, moving shared setup into let/subject blocks, and replacing should with expect syntax in new tests.

Frequently Asked Questions about rspec

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

FAQPage Schema
How do I structure RSpec tests to follow best practices?

RSpec test structure best practices involve organizing top-level describe blocks by class, nesting context blocks for conditions, and grouping let, subject, and before blocks at the top for consistency. This improves test readability and maintainability.

What is the proper way to use let and subject in Ruby specs?

In Ruby specs, use let and let! for lazy and pre-evaluated memoization respectively, and utilize named subjects to improve readability. This ensures robust and maintainable test setup across unit and integration tests.

Should I use should or expect syntax in Rails testing?

You should use the expect syntax in Rails testing instead of the older should syntax. The expect syntax is the established standard promoted by the RSpec Style Guide for writing clear and robust expectations.

When do I need verified doubles in RSpec integration tests?

You need verified doubles in RSpec integration tests to prevent stubbed methods from becoming out of sync with actual implementations. Using verified doubles is a best practice that makes your test suite more robust.

Can I apply RSpec style guides to request specs and model specs?

Yes, you can apply RSpec style guides to request specs, model specs, and integration tests. The guidelines help structure describe/context blocks and enforce proper matcher usage across all Ruby and Rails test types.

What are the limitations of using Better Specs for Ruby testing?

Better Specs focuses on formatting and structural conventions for Ruby testing, such as let placement and context nesting. It provides guidance rather than automated linting, requiring manual application of style patterns to your test suite.