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 ...
Get Rails 4 Test Prescriptions 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.