Skip to content
Given-when-then for Test::Unit (or "If shoulda and cucumber had a baby")
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
tag_test Only correctly tagged features run when running with that tag is spec…
test Updated to use yourdsl
.gitignore Development now uses Bundler 1.0.0; Added Coulda#default_testcase_cla…
LICENSE Updated for 2010 and 2011
Rakefile Refactored around my fork of lispy (0.1.2)
coulda.gemspec Updated to use yourdsl
geminstaller.yml updated



Coulda gives you Cucumber-like BDD power but with an internal DSL. This means no “call-by-regexp” and no Gherkin/plain-text/external DSL. Coulda is just code – but with a Cucumber-like take on BDD.

Coulda, obviously was inspired by Cucumber, Shoulda, but also Thor. Coulda believes that the best way to reuse code is the good ol' fashioned method. Instead of sharing files of regexps mapped to procs, you just write methods. That simple.

You can define the implementation of your Given/When/Then right there with the behavior description. Or, if you want to reuse some Givens/Whens/Thens, just write a method! And if you find your Feature is getting too bloated or that you would like to reuse Givens/Whens/Thens between features, put them in a helper.

Coulda also easily supports your Test::Unit framework of choice (including Rails Tests).

See for more information.

Easy as pie.

require 'rubygems'
require 'coulda'
include Coulda

Coulda.default_testcase_class = ActiveSupport::TestCase

Feature "feature name" do
  in_order_to "foo"
  as_a "bar"
  i_want_to "blech"

  def given_something

  Scenario "pending scenario"

  Scenario "another scenario" do
    Given "a pending prereq"
    When "something happens" do
      # an event here
    Then "expect something else" do
      # assert something here

  Scenario "that is live" do
    When "bar" do; end
    Then "blech" do; end

Thanks to

  • David Chelimsky and Jim Weirich for turning me into the test-obsessed developer that I am.

  • Timothy King for putting up with my scotch-powered rambling while working on v0.4.0

  • We Are Titans ( for sponsoring v0.4.0 through 0.5.5

Something went wrong with that request. Please try again.