Add the gems to your Gemfile
group :development, :test do gem 'rspec-rails' gem 'factory_girl_rails' end group :test do gem 'capybara' end
Download and install
$ bundle install
Initialize the spec directory
$ rails g rspec:install
Require Capybara
#spec/spec_helper.rb require 'capybara/rspec'
Drop in your factories into /spec/factories/MODEL_NAMES.rb (replace model_names with the actual name of your models.
Factory example for a Contact model
#spec/factories/contacts.rb
FactoryGirl.define do
factory :contact do
name 'John Doe'
end
end
Run your tests
$ bundle exec rspec spec
GitHub links: