Setting up capybara with rails - marklocklear/railsgirls GitHub Wiki
Add the Capybara gem to your Gemfile
group :development, :test do
gem 'sqlite3'
gem 'rspec-rails', '~> 2.0'
gem 'factory_girl_rails'
gem 'shoulda-matchers'
gem 'ffaker'
gem 'debugger'
gem 'capybara'
gem 'selenium-webdriver'
end
Tell RSpec to use Capybara
Here we let rspec know about Capybara. Open spec/spec_helper.rb
and add the following lines:
# Add this to load Capybara integration:
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
require 'capybara/rspec'
require 'capybara/rails'
include Capybara::DSL
You’re all set! Capybara’s DSL will be available in all RSpec examples in the spec directory. So, for example, in spec/integration/home_spec.rb you might write:
require 'spec_helper'
describe 'home page' do
it 'welcomes the user' do
visit '/'
page.should have_content('Welcome')
end
end
Run rake spec
to run it.