Installation

Rails provides infrastructure for directly testing specific pieces of your application: models, views, controllers, and so on. It also supports tests that integrate multiple layers and acceptance tests that integrate all layers.

The rspec-rails gem adapts the Rails testing infrastructure for use from RSpec. To use it, add an entry like the following one to the :development and :test groups in your Gemfile:

 group ​:development​, ​:test​ ​do
» gem ​'rspec-rails'​, ​'~> 3.6'
 end

Then, run bundle install to install rspec-rails. Finally, you can set your project up to use rspec-rails with the following command:

 $ ​​rails generate rspec:install
  create .rspec
  create spec
  create ...

Get Effective Testing with RSpec 3 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.