On this page
Overview
This testing library integrates RSpec with Ruby on Rails so application behavior can be expressed and checked as specs. It provides spec types and matchers for models, requests, systems, jobs, mailers, and other Rails facilities. Generators create the initial configuration and boilerplate for application components.
Features and best fit
Based on official documentation; not hands-on tested · Content checked:
Key features
Test Rails layers with purpose-specific spec types
Model, request, system, controller, view, routing, job, mailer, and other spec types cover different application boundaries. Rails TestCase facilities and test helpers are combined with RSpec expectations to check results, HTTP responses, and browser interactions.
Sources: [1]
Generate boilerplate and run a focused test scope
rails generate rspec:install creates configuration and helper files, while Rails generators can create matching specs for application components. bundle exec rspec can target the whole suite, a directory, one file, or an example at a line number.
Sources: [1]
Best fit
Share expected Rails behavior in executable specifications
It fits teams that want the same specification style from user-facing HTTP or browser behavior down to models and jobs. Request and system specs are especially useful when tests should cross Rails boundaries rather than isolate a controller implementation.
Sources: [1]
Before adoption
Select the major version that matches Rails and Ruby
v8.0.4 targets Rails 8.0 or 7.2, and its gemspec requires Ruby 3.0 or newer plus Rails 7.2 or newer. The selected Rails release may impose a higher Ruby requirement. Older Rails applications need the corresponding earlier major. Removing Rails or Ruby support is treated as a breaking change, so review upgrade notes and the changelog before moving between majors.
Official sources
- [1]RSpec Rails v8.0.4 README(2026-10-04)
- [2]RSpec Rails v8.0.4 gem specification(2026-10-04)
- [3]RSpec Rails v8.0.4 changelog(2026-10-04)
- [4]RSpec Rails versioning strategy(2026-10-04)
- [5]RSpec Rails GitHub repository metadata(2026-10-04)
- [6]RSpec Rails v8.0.4 MIT license(2026-10-04)
Supplemental curator note
Choose each spec type by the boundary a failure should identify. Request specs fit HTTP behavior, while system specs fit user interactions; adding every layer by habit can make the suite slower and harder to diagnose.
Try it in 3 steps
- 1
Add RSpec Rails to an existing Rails application
Run this at the root of an evaluation app using Rails 8.0 or 7.2 and a Ruby version supported by that Rails release. Bundler updates the Gemfile and installs dependencies.
bundle add rspec-rails --version 8.0.4 --group development,test - 2
Generate the RSpec configuration
Generate
.rspec,spec/spec_helper.rb, andspec/rails_helper.rb.bundle exec rails generate rspec:install - 3
Run a minimal spec that loads Rails
Create a small spec and confirm that it passes while loading the Rails test environment.
mkdir -p spec/models && printf '%s\n' "require 'rails_helper'" "RSpec.describe 'smoke' do" " it 'runs inside Rails' do" " expect(Rails.env.test?).to be(true)" " end" "end" > spec/models/smoke_spec.rb && bundle exec rspec spec/models/smoke_spec.rb
Growth
Growth trends · Last 30 days
5,276 Stars
Trend data is still being collected.
Development activity
Last 90 days · weekly
- Commits (last 30 days)
- 6
- Open PRs
- 20
Development activity is still being collected.
Built with
Categories and tags
Categories
GitHub data
GitHub dataView detailed GitHub data
Related information
Write a related articleShare a guide or use case for this OSS in Markdown. Articles are published after administrator approval.
Explore next
- Vitest17,180 Stars
2 shared tag(s) · 2 shared category(s)
reuse Vite transforms and configuration across Node, DOM, and Browser Mode tests
TypeScript - JUnit7,056 Stars
2 shared tag(s) · 2 shared category(s)
Java/JVM testing built on Platform and Jupiter
Java - MockK5,762 Stars
2 shared tag(s) · 2 shared category(s)
mock, stub, and verify Kotlin collaborators with coroutine and Android support
Kotlin - Kotest4,789 Stars
2 shared tag(s) · 2 shared category(s)
combine spec styles, assertions, and property testing across Kotlin projects
Kotlin - Fluent Assertions3,813 Stars
2 shared tag(s) · 2 shared category(s)
express expected outcomes and failure reasons in .NET unit tests through readable
C#.Should()-style assertions - Letter Opener3,838 Stars
2 shared tag(s) · 1 shared category(s) · Same language
Preview development emails in a browser without sending them
Ruby
Report incorrect information
Tell us if any listing information is incorrect or outdated.