The new hotness coming out of the RSpec camp is Cucumber. In their own words, “Cucumber executes plain text documentation of code against that code.” In normal people speak, Cucumber provides an extremely easy way to write acceptance style tests for your applications.
To get started, I installed Cucumber per their directions. I’m using this with a Rails project, and the steps from the wiki put me on the right track. (I did already have RSpec installed, but we won’t be using that here) I’m using this with a Rails 2.2, project, so I’ve added the following to my environment.rb:
config.gem "cucumber", :version => "0.1.9"
Next, I bootstrapped Cucumber, and started working on my features.
Seeing as how I don’t do much Rspec these days, I wanted to see if it would be possible to use Cucumber with Test::Unit. Fortunately for us, this is a very easy task, and I’ll share my notes with you.
1. Make sure the ‘require’ spec line is commented out in features/support/env.rb.
2. Modify the steps in features/step_definitions/webrat_steps.rb
Mostly, what you will do here is convert the matchers to thier Test::Unit equivalents. For instance, response.body.should_not =~ /#{text}/m is synonymous to assert_no_match(response.body, /#{text}/m)
3. There is no step 3.
So I’ve using this for a few days, I’ve noticed nothing weird, and I will be using this in all my projects. Thanks to RSpec team for creating such a cool project.