Skip to content

Instantly share code, notes, and snippets.

@cjgiridhar
Created October 11, 2012 05:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cjgiridhar/3870274 to your computer and use it in GitHub Desktop.
Save cjgiridhar/3870274 to your computer and use it in GitHub Desktop.
Lettuce Example Python BDD
from lettuce import *
@step('I have the number (\d+)')
def have_the_number(step, number):
world.number = int(number)
@step('I compute its fibonacci')
def compute_its_fibonacci(step):
world.number = fibonacci(world.number)
@step('I see the number (\d+)')
def check_number(step, expected):
expected = int(expected)
assert world.number == expected
def fibonacci(number):
number = int(number)
if (number == 0) or (number == 1):
return 1
else:
return fibonacci(number-1) + fibonacci(number-2)
~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment