Coder Social home page Coder Social logo

steak's Introduction

Steak

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"
  end

  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")
    end
  end

end

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

Not in Rails

Just install and require the damned gem!

$ gem install steak

(Add the --pre modifier to be on top of RSpec 2 instead of RSpec 1.x)

Then in your spec or spec helper:

require 'steak'

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

In Rails 2.x (stable branch)

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 Capybara. If you want to use Webrat, just pass it to the generator:

$ script/generate steak --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…

$ rspec spec/acceptance/this_is_my_first_feature_spec.rb

…or all together:

$ rspec spec/acceptance

…you can also do:

$ rake spec:acceptance

In Rails 3 (master branch)

Add this to your project’s Gemfile:

group :test do
  gem 'steak', :git => 'git://github.com/cavalle/steak.git'
end

And install it:

$ bundle install

Run the generator:

$ rails generate steak:install

That will create some basic helper files and directory structure under the spec/acceptance directory, already configured for Capybara. If you want to use Webrat, just pass it to the generator:

$ rails generate steak:install --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:

$ rails generate steak:spec this_is_my_first_feature

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

$ rspec spec/acceptance/this_is_my_first_feature_spec.rb

…or all together:

$ rspec spec/acceptance

…you can also do:

$ rake spec:acceptance

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

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

steak's People

Contributors

cavalle avatar alvarobp avatar jaimeiniesta avatar flype avatar raul avatar wincent avatar eparreno avatar

Stargazers

 avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.