Skip to content

Instantly share code, notes, and snippets.

@cadyherron
Last active February 29, 2016 23:58
Show Gist options
  • Save cadyherron/7b8e1940d126e89b9175 to your computer and use it in GitHub Desktop.
Save cadyherron/7b8e1940d126e89b9175 to your computer and use it in GitHub Desktop.
How to setup RSpec, Capybara, and Factory Girl for Rails project

Note: you want to do include -T when you first run rails new

  1. add the following to your Gemfile:

    group :development do gem 'guard-rspec', require: false end

    group :test do gem 'capybara' gem 'launchy' end

    group :development, :test do gem 'rspec-rails' gem 'factory_girl_rails', '~> 4.0' end

  2. rails g rspec:install

  3. add the following at the top of your rails_helper.rb file:

    require 'factory_girl_rails

    require 'capybara/rails'

      config.include FactoryGirl::Syntax::Methods
    end```
    
    
  4. at the top of each spec file, include require 'rails_helper'

  5. add --format documentation to the .rspec file

  6. start testing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment