add to your Gemfile

group :development, :test do
 gem ‘rspec-rails’
end

Be sure to bundle install after changing your Gemfile

rails generate rspec:install

This creates a few files in your project:

.rspec a config file. (By default only --colour is in this file which turns on colored output)
spec a directory that will store all of the various model, controller, view, acceptance and other specs for your app
spec/spec_helper.rb a file that’s loaded by every spec will have require ‘spec_helper’ at the top. This sets the test environment, contains app level RSpec configuration items, and loads support files

To run specs, type rake at the command line. If you want to isolate just the model tests, you can run rake spec:models

By Jason

Leave a Reply

Your email address will not be published. Required fields are marked *