codeBrane Blog

Software development and philosophical musings

Say Hello to Cucumber!

BDD is looking good!

fruit-patch
Rakefile
  +- features
       fruity.feature
    +- step_definitions
          fruity_steps.rb

and what do the fruity contents contain?

Rakefile:

require 'cucumber/rake/task'
Cucumber::Rake::Task.new(:features)
task :default => :features

fruity.feature:

Feature: Fruityness
  Cucumber is a fruit and not a vegetable!

Scenario: Say Hello to Cucumber
  Given that I don't know Cucumber, say Hello Cucumber!

fruity_steps.rb:

Given /^that I don't know Cucumber, say (.*)$/ do |message|
  puts(message)
end

and the fruity result:

$ rake
...
Feature: Tasks
 Cucumber is a fruit and not a vegetable!

Scenario: Say Hello to Cucumber
 # features/test.feature:4
Hello Cucumber!
Given that I don't know Cucumber, say Hello Cucumber!
  # features/step_definitions/test_steps.rb:1

1 scenario (1 passed)
1 step (1 passed)
0m0.001s

Now to apply it to CouchKit.