Cucumber And Bdd

Preview:

Citation preview

Cucumber and BDDNashville Ruby on Rails meetup

November 19, 2009Josh Crews

Behavior Driven Development (BDD)

first: describe what the software doessecond: write the code to fulfill it(behavior drives development)

BDD

Separate software design (one job)fromwriting code (a different job)

BDD - design example

Given I am a bureau owner When I go to the homepage And I am logged in When I go to the speakers page And I click on "Add a speaker" And I fill in "speaker_name" with "Tad" And I press "Create profile" Then I should see "Tad" And I should see "Exclusive with Steve's speakers"

Cucumber

software for BDD that takes plain english,Ruby translations of plain english,and runs integration test/stories against your application

Cucumber - step definition

Given /^I am a bureau owner$/ do bureau = Factory(:bureau, :name => "Steve's speakers") @user = Factory(:user, :bureau => bureau)end

Cucumber’s sidekick: webrat

Cucumber reads the storyWebrat drives the browser

When /^I go to (.+)$/ do |page_name| visit path_to(page_name)end

Cucumber benefits

Joy in programmingclears the mindcontrols feature-driftdefines mini-milestones and git commits

Cucumber benefits

Leaves a trail of feature-still-works guaranteesEasy re-factor with confidence

Cucumber setup

http://cukes.info/Railscasts #155, #159

Cucumber: other

Not a direct replacement for Test::Unit, Shoulda, RspecCucumber can run integration tests on any application (different languages or frameworks)

Cucumber: Let’s use it!

End of presentation--now to the terminal.