O'Reilly logo

Effective Testing with RSpec 3 by Myron Marston, Ian Dees

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required