Discontinued
This library is no longer maintained. Capybara itself included the same functionality.
Steak
The delicious combination of RSpec and Capybara for Acceptance BDD
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 an 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'
login_as '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:
- 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.
- 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.
- 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 current version of Steak (2.0) assumes that you're testing a Rails 3 application, with RSpec 2 and Capybara. For Rails 2, RSpec 1 or Webrat you should use Steak 1 (or consider upgrading to non-obsolete technologies ;P)
It's super-easy to get you started. Just add the gem to your Gemfile
…
group :test, :development do
gem 'steak'
# ...
…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…
$ bundle exec rspec spec/acceptance/my_first_feature_spec.rb
…or using rake:
$ rake spec:acceptance
Resources
- Source code – Lurking and forking
- Issues – Bugs and feature requests
- Google Group & IRC channel – Help and discussion
- Twitter – Announcements and mentions
- Wiki – Tutorials, docs and other resources
Credits
Steak was created by Luismi Cavallé and improved thanks to the love from:
- Álvaro Bautista
- Felipe Talavera
- Paco Guzmán
- Jeff Kreeftmeijer
- Jaime Iniesta
- Emili Parreño
- Andreas Wolff
- Wincent Colaiuta
- Falk Pauser
- Francesc Esplugas
- Raúl Murciano
- Enable Interactive
- Vojto Rinik
- Fred Wu
- Sergio Espeja
- Joao Carlos
Copyright © 2009 - 2011 Luismi Cavallé, released under the MIT license