Logo: Relish

  1. Sign in

Project: RSpec Rails 6.0

RSpec Rails 6.0

rspec-rails extends Rails' built-in testing framework to support rspec
examples for requests, controllers, models, views, helpers, mailers and


rspec-rails 6 supports Rails 6.1 to 7.0. For earlier versions of Rails, you
should use rspec-rails-5 for Rails 5.2 and 6.0, rspec-rails-4
for Rails 5.x, and rspec-rails 3
for even older versions.


gem install rspec-rails

This installs the following gems:



Add rspec-rails to the :test and :development groups in the Gemfile:

group :test, :development do
  gem 'rspec-rails', '~> 6.0.0'

It needs to be in the :development group to expose generators and rake tasks
without having to type RAILS_ENV=test.

Now you can run:

bundle exec rails generate rspec:install

This adds the spec directory and some skeleton files, including a .rspec

You can also customize the default spec path with --default-path option:

bundle exec rails generate rspec:install --default-path behaviour


The documentation for rspec-rails is a work in progress. We'll be adding
Cucumber features over time, and clarifying existing ones. If you have
specific features you'd like to see added, find the existing documentation
incomplete or confusing, or, better yet, wish to write a missing Cucumber
feature yourself, please submit an issue or a pull request.


  1. Start from scratch
  2. Generators
  3. Transactions
  4. Changelog
  5. Rails versions
  6. Directory Structure
  7. backtrace filtering
  8. Model specs
  9. Controller specs
  10. Matchers
  11. Request specs
  12. Feature specs
  13. View specs
  14. Helper specs
  15. Mailer specs
  16. Routing specs
  17. Channel specs
  18. file fixture
  19. Generator specs
  20. Job specs
  21. Mailbox specs
  22. System specs
  23. Upgrade

Last published 3 months ago by Jon Rowe.