rspec-rails connects the RSpec DSL to Ruby on Rails as a testing layer. It adds Rails-focused matchers and spec types for models, requests, and system tests.
Overview
rspec-rails brings the RSpec testing framework to Ruby on Rails as a drop-in alternative to its default testing framework, Minitest. Specs read as executable descriptions of expected application behavior in plain English plus example code.
The gem tracks supported Rails versions across major rspec-rails releases. Rails generators can scaffold spec files, and the suite can run via bundle exec rspec or a binstub.
Extra matchers delegate to Rails assertions for templates, redirects, routes, HTTP status, ActiveJob enqueue checks, and array comparisons. Spec types mirror Rails test cases for models, controllers, mailers, jobs, views, routing, helpers, requests, features, and system tests.
Documentation points to Cucumber-hosted guides for DSL basics and framework features. Version upgrades follow semantic versioning with dedicated upgrade notes.
Key features
- Rails spec type generators
- Rails-specific matchers
- Model and request specs
- System and feature specs
- ActiveJob matchers
- Semantic versioning policy
Use cases
- Rails app test suites
- Request and routing specs
- Browser system tests
- Replacing Minitest on Rails