Skip to content

Instantly share code, notes, and snippets.

@msassak
Created November 22, 2010 08:18
Show Gist options
  • Select an option

  • Save msassak/709666 to your computer and use it in GitHub Desktop.

Select an option

Save msassak/709666 to your computer and use it in GitHub Desktop.
The Gherkin Builder API
require 'gherkin'
require 'gherkin/builder'
gherkin = Gherkin::Builder.new do
feature "Addition" do
description "In order to avoid silly mistakes..."
scenario_outline "Add two numbers" do
step :given, "I have entered <input_1> into the calculator"
step :and, "I have entered <input_2> into the calculator"
step :when, "I press <button>"
step :then, "the result should be <output> on the screen"
examples "Needs a default" do
row ["input_1", "input_2", "button", "output"]
row ["20", "30", "add", "50"]
row ["2", "5", "add", "7"]
row ["0", "40", "add", "40"]
end
end
end
end
puts gherkin.to_gherkin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment