There are two reasons for the name:
- Lettuce is a green vegetable, just like cucumber the idea is that your tests must be always green.
- Letuce is the name of a brazillian band that I pretty much like
There are links to lettuce's official documentation at the end of this post, but there is a sneak peak:
Features are described in files with .feature extension and must be, by defaul within your project, in a folder called "features".
Features are described like this:
1 Feature: Introduce lettuce to my friends 2 In order to show it working 3 As lettuce author 4 I want to create a scenario that passes 5 6 Scenario: Concatenate names 7 Given I have the following names: 8 | name | surname | 9 | john | doe | 10 | ian | murdock | 11 When I join them 12 Then I see the data: 13 | joined | 14 | Doe, John | 15 | Murdock, Ian |
In order to define steps all you need to do is write a new python file wihin features folder, Lettuce will import them all, recursively.
1 # -*- coding: utf-8 -*- 2 from lettuce import step, world, before 3 from some_module import NameJoiner 4 5 # setup 6 @before.each_scenario 7 def set_joined(scenario): 8 world.joined =  9 10 # steps 11 @step('I have the following names') 12 def set_names(step): 13 world.people = step.hashes 14 15 @step('join them') 16 def join_names(step): 17 for person in world.people: 18 joiner = NameJoiner( 19 name=person["name"], 20 surname=person["surname"] 21 ) 22 world.joined.append(joiner.join()) 23 24 @step('I see the data') 25 def check_names(step): 26 for name, data in zip(world.joined, step.hashes): 27 assert name == data['joined']
(the full example is available here aqui)
Since I started with TDD in Python I had many experiences, I've tested many mock mock libraries and test techniques. In web projects I've used Pyccuracy, so that I could both describe behaviour of the application and make automated acceptance tests.
Althrough, I had a chance to try Cucumber with Django here at globo.com, and the result was: I fell in love with it, and had incredibly productive features, such as step tables which allows drawing a ascii table and map it into a list of hashes, and the scenario outlines.
From there I had THE inspiration: to implement a tool that works exactly like Cucumber, but in python.
Python programmers it's easier and frictionless to use libraries written in Python. I personally avoid mixing programming languages in a single project, some technologies can suit perfectly in the project, no matter in what language, but if there is a Python option, I will give it a go.
Cucumber IMHO one lib to make ruby even more "sexy" :) Build a robust application, well tested required patience, what about turn it into fun ! ? It's easier to package python modules for debian/ubuntu.
Besides, even considering the fact that Cucumber already supports, would be more interesting to user pure python within step definitions. Supposing that a web application will be written with Django and Cucumber, would be very useful to manipulate models within step definitions. However turning it possible, would need efforts to run rubypython, which the latest release dates october 2009.
Examples of similar libraries between python and ruby
Micro web framework:
ruby: capistrano python: fabric
More on lettuce
Available at http://lettuce.it covers all supported features until now.
I'll appreciate all kinds of feedback, to do so we have some channels:
Lettuce is under GNU GPL 3+ and have a long way until get robust, and any kind of help is welcome: patches, documentation, language support and so on!
Grab it, and happy hacking :)