From the archive. This was written in 2011 and is kept here unchanged. Some of it has aged better than the rest.

Rails has some amazing testing tools (clearly written by some hungry developers) so there’s no doubt that we are spoiled for choice when it comes to testing any aspect of our applications. Despite this, it’s safe to say that when it comes to acceptance testing, I’m between solutions.

So with Spinach throwing it’s vegetable hat in the ring this recently, and with Steak now haivng been consumed by Capybara I felt like it was time to sit down and see how these options look side by side.

Checkout the demo app here

The overly simple example

# features/articles.feature
Feature: Articles
  In order to make a blog
  As an author
  I want to create and manage articles

  Scenario: Articles List
    Given I have articles titled "Bacon" and "Cheese"
    When I go to the list of articles
    Then I should see "Bacon"
    And I should see "Cheese"

Cucumber

# features/step_definitions/article_steps.rb
Given /^I have articles titled "([^"]*)" and "([^"]*)"$/ do |*titles|
  titles.each { |title| Article.create!(:title => title) }
end

When /^I go to the list of articles$/ do
  visit articles_path
end

Then /^I should see "([^"]*)"$/ do |title|
  page.has_content? title
end

Capybara

# features/articles_spec.rb
feature "Articles", %q{
  In order to make an awesome blog
  As an author
  I want to create and manage articles
} do

  background do
    ["Bacon","Cheese"].each { |title| Article.create!(:title => title) }
  end

  scenario %q{
    Given I have articles titled "Bacon" and "Cheese"
    When I go to the list of articles
    Then I should see "Bacon"
    And I should see "Cheese"
} do
    visit articles_path
    page.has_content? "Bacon"
    page.has_content? "Cheese"
  end

end

Spinach

# features/steps/articles.rb
class Articles < Spinach::FeatureSteps
  feature 'Articles'
  Given 'I have articles titled "Bacon" and "Cheese"' do
    ["Bacon","Cheese"].each { |title| Article.create!(:title => title) }
  end

  When 'I go to the list of articles' do
    visit articles_path
  end

  Then 'I should see "Bacon"' do
   page.has_content? "Bacon"
  end

  And 'I should see "Cheese"' do
   page.has_content? "Cheese"
  end
end