Not every app is setup to run capybara tests, but many have an existing testing framework that we'll have to integrate with. Here are some common frameworks we'll come across.
If there's no existing testing framework, let's setup this app with rspec, which is preferred.
- 
Add the following to Gemfile:group :test do gem 'rspec-rails' gem 'capybara-rails' gem 'factory_girl_rails' end 
- 
Run bundleto install. (If you get an error aboutGemfilespecifying a different ruby version than the local one, you may have to install a different ruby version usingrbenv install 1.2.3-p456)
- 
Run rails generate rspec:install
- 
Change the RSpec.configure do |config|line inspec/spec_helper.rbfile to look like this:require 'capybara/rspec' require 'rails_helper' require 'database_cleaner' RSpec.configure do |config| config.include FactoryGirl::Syntax::Methods config.before(:suite) do begin DatabaseCleaner.strategy = :transaction DatabaseCleaner.clean_with(:truncation) FactoryGirl.lint ensure DatabaseCleaner.clean end end config.around(:each) do |example| DatabaseCleaner.cleaning do example.run end end 
- 
For each model in app/models/model_name.rb, runrails generate factory_girl:model ModelNameand then change the files intest/factories/model_name.rb