Steak

The delicious combination of RSpec and Capybara for Acceptance BDD

Steak!!

What is Steak?

Steak is a minimal extension of RSpec-Rails that adds several conveniences to do acceptance testing of Rails applications using Capybara. It's an alternative to Cucumber in plain Ruby. This is how and acceptance spec looks like in Steak:

feature 'Main page' do

  background do
    create_user :login => 'jdoe'
  end

  scenario 'should show existing quotes' do
    create_quote :text => 'The language of friendship is not words, but meanings',
                 :author => 'Henry David Thoreau'

     'jdoe'
    visit '/'

    within('.quote') do
      page.should have_content('The language of friendship is not words, but meanings')
      page.should have_content('Henry David Thoreau')
    end
  end

end

No givens, whens or thens. No steps, no english, just Ruby. The delicious combination of RSpec and Capybara. That's Steak!

Why Steak?

If, after all, this is just RSpec + Capybara, why does Steak even exist? Do I really need it?

Basically Steak exists for three reasons:

  1. Making a point. First of all, Steak proposes that using RSpec and Capybara for acceptance testing is a sensible alternative to Cucumber. It also sets a name to refer to that approach.
  2. Adding convenience. As a gem, Steak aims to make the experience as convenient as possible. It provides Rails integration testing support and several generators and rake tasks so that setting up a new project or creating and running specs are quick and seamless tasks. A natural extension of RSpec-Rails.
  3. Building a community. No development approach or ruby gem is really valuable without an active community behind it. The mailing list, the IRC channel, the wiki or the twitter account are useful tools to build a community of users that help each other by sharing knowledge, resources and best practices.

Getting Started

NOTE: The following instructions refer to the development version of Steak which only works for Rails 3, RSpec 2 and Capybara 1.0. The stable version, also works for Rails 2, RSpec 1 or Webrat

It's super-easy to get you started. Just add the gem to your Gemfile

group :test, :development do
  gem 'steak', '>= 2.0.0.beta1'
  # ...

…and then install the gem and run the generator:

$ bundle
$ rails g steak:install

You're now set up! Note that Steak is the only dependency you really need, you can safely remove any reference to capybara, rspec-rails or rspec from your Gemfile, they will be included by Steak. Also note that, unless previously executed, Steak will run the RSpec generator so you don't need to invoke it.

Take a look now at the default directory structure you've got under spec/acceptance. It will help you organize the helpers and configurations for your acceptance specs.

Creating and running specs

You can create your specs by hand, however you may prefer to use the generator:

$ rails g steak:spec my_first_feature

To run your acceptance specs you just do like with any other spec…

$ rspec spec/acceptance/my_first_feature_spec.rb

…or using rake:

$ rake spec:acceptance

Resources

Credits

Steak was created by Luismi Cavallé and improved thanks to the love from:

Copyright © 2009 - 2011 Luismi Cavallé, released under the MIT license