O'Reilly logo

Rails 4 Test Prescriptions by Noel Rappin

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

Installing RSpec

Before we start testing, we’ll need to load RSpec, our testing library.

We’ll be talking about RSpec 3, which has some significant syntactical differences from previous versions. We’ll largely ignore those differences and focus on only the new syntax.

To add RSpec to a Rails project, add the rspec-rails gem to your Gemfile:

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

The rspec-rails gem depends on the rspec gem proper. The rspec gem is mostly a list of other dependencies where the real work gets done, including rspec-core, rspec-expectations, and rspec-mocks. Sometimes rspec and rspec-rails are updated separately; you might choose to explicitly specify both versions in the Gemfile. Also, rspec

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