Skip to content

Instantly share code, notes, and snippets.

@cavalle
Created November 7, 2011 16:22
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save cavalle/1345423 to your computer and use it in GitHub Desktop.
Save cavalle/1345423 to your computer and use it in GitHub Desktop.
Meatloaf (Just another scam)
require 'meatloaf'
require 'steps'
Feature "Eat candies" do
Scenario "Eat a candy from a jar full of them" do
Given "I have a jar with candies", candies: 10
When "I eat one candy"
Then "the jar won't be empty"
end
Scenario "Eat the last candy" do
Given "I have a jar with candies", candies: 1
When "I eat one candy"
Then "the jar will be empty"
end
end
#
# | \/ | | | | | / _|
# | \ / | ___ __ _| |_| | ___ __ _| |_
# | |\/| |/ _ \/ _` | __| |/ _ \ / _` | _|
# | | | | __/ (_| | |_| | (_) | (_| | |
# |_| |_|\___|\__,_|\__|_|\___/ \__,_|_|
#
# ~ JUST ANOTHER SCAM ~
#
# Get the 95% of Cucumber with just 6 aliases
#
require 'minitest/spec'
alias Feature describe
alias Given send
alias When send
alias Then send
class << MiniTest::Spec
alias Scenario it
end
class Module
alias Step define_method
end
module Steps
Step "I have a jar with candies" do |attrs|
@jar = Jar.new(attrs[:candies])
end
Step "I eat one candy" do
@jar.eat_candy
end
Step "the jar will be empty" do
@jar.empty?.must_equal true
end
Step "the jar won't be empty" do
@jar.empty?.wont_equal true
end
end
MiniTest::Unit::TestCase.send :include, Steps
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment