Logo: Relish

  1. Sign in

Project: RSpec Rails 4.0

RSpec Rails 4.0

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

Rails

rspec-rails 4 supports Rails 5.x and 6.x. For earlier versions of Rails, you
need rspec-rails 3.

Install

gem install rspec-rails

This installs the following gems:

rspec
rspec-core
rspec-expectations
rspec-mocks
rspec-rails

Configure

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

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

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:

script/rails generate rspec:install

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

Issues

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.

Topics

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

Last published about 1 month ago by benoit.