Minimalist acceptance testing on top of RSpec
Clone or download
Pull request Compare This branch is 1 commit ahead, 144 commits behind cavalle:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



Minimalist acceptance testing on top of RSpec

What is Steak?

Steak is like Cucumber but in plain Ruby. This is how an acceptance spec looks like in Steak:

feature "Main page" do

  background do
    create_user :login => "jdoe"
    login_as "jdoe"

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

    visit "/"

    page.should have_css(".quote", :count => 1)
    within(:css, ".quote") do
      page.should have_css(".text", :text => "The language of friendship is not words, but meanings")
      page.should have_css(".author", :text => "Henry David Thoreau")


No explicit givens, whens or thens. No steps, no english, just Ruby: RSpec, Steak and, in this example, some factories and Capybara. That's all.

If you are not in Rails but use RSpec, then Steak is just some aliases providing you with the language of acceptance testing (feature, scenario, background). If you are in Rails, you also have a couple of generators, a rake task and full Rails integration testing (meaning Webrat support, for instance)

Getting started

NOTE: Please note that the stable version of Steak only works with Rails 2.x and RSpec 1.x. If you want to try with Rails 3 or RSpec 2, then you can install the prerelease version of Steak (using gem install steak --pre) which is based on the experimental rails3 branch.

Not in Rails

Just install and require the damned gem!

$ gem install steak

Then in your spec or spec helper:

require 'steak'

That's all. You don't really need to require RSpec.

In Rails

Assuming you have already setup rspec-rails, add this to your project's config/environments/test.rb:

config.gem "steak"

Install the gem from the command line:

$ RAILS_ENV=test rake gems:install

Run the generator:

$ script/generate steak

That will create some basic helper files and directory structure under the spec/acceptance directory, already configured for Webrat. Spend one minute on getting familiar with the structure and files you've got.

Now you may want to create your first acceptance spec:

$ script/generate acceptance_spec this_is_my_first_feature

You run your acceptance specs just like your regular specs. Individually…

$ spec spec/acceptance/this_is_my_first_feature_spec.rb

…or all together:

$ spec spec/acceptance

…you can also do:

$ rake spec:acceptance


Steak is developed and maintained by Luismi Cavallé with the help and support of the rest of the BeBanjo team: Sergio Gil and Jorge Gómez Sancha.

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