A simple acceptance test for the RailsGirls Ideas App.
Add the following lines to your Gemfile:
gem 'rspec-rails'
gem 'capybara'
Install the gems by running
bundle install
Run the following command to set up the test runner, RSpec:
rails generate rspec:install
Next, we will enable Capybara, our browser test library:
- Open
spec/spec_helper.rb
- underneath
require 'rspec/autorun'
add the following line:
require 'capybara/rails'
This is telling RSpec we want to use Capybara.
- (optional) underneath
RSpec.configure do |config|
, add:
config.before { Capybara.default_driver = :selenium }
This tells Capybara that we want to use the 'Selenium' driver; this is a tool for automatically clicking through our app in a Firefox window.
Create a new file spec/ideas_spec.rb
with the following content:
require 'spec_helper'
feature "Ideas" do
scenario "start at the ideas page" do
visit '/'
page.should have_content 'Ideas'
end
end
We can now run all our tests (right now there's only one) by running:
bundle exec rspec