behavior driven development cucumber · behavior driven development. feature: cucumber in order to...
TRANSCRIPT
Cucumber
http://flickr.com/photos/nickatkins/527421404/
Brandon Keepers ● Collective idea ● http://opensoul.org
withBehavior Driven Development
Feature: Cucumber In order to share the love As a presenter I will demonstrate behavior driven development with Cucumber
Scenario: Behavior Driven Development with Cucumber Given a desire for higher quality software And a tool that executes feature documentation written in plain text When you watch this presentation Then you will gain an understanding of behavior driven development And see examples of behavior driven development with cucumber And be equipped to integrate Cucumber into your development process
Quality
1Qualitymeets requirements
Developer
Client
Language
Developer
Client
Stories
In order to keep of track movies that I want to seeAs a NetFlix customerI can add movies to a queue
http://dannorth.net/whats-in-a-story
In order to keep of track movies that I want to seeAs a NetFlix customerI can add movies to a queue
http://dannorth.net/whats-in-a-story
value proposition
In order to keep of track movies that I want to seeAs a NetFlix customerI can add movies to a queue
http://dannorth.net/whats-in-a-story
role
In order to keep of track movies that I want to seeAs a NetFlix customerI can add movies to a queue
http://dannorth.net/whats-in-a-story
feature
2Qualityworks as expected
Test Driven
Behavior Driven
Verify
Confidence
Design
Behavior
Testing
Specifying
Cucumber
http://flickr.com/photos/nickatkins/527421404/
rbehave
rSpec Story Runner
Cucumber
http://github.com/aslakhellesoy/cucumber
$ gem install cucumber
require 'rubygems'require 'cucumber/rake/task' Cucumber::Rake::Task.new
Rakefile
$ rake features
Rails
$ ruby script/plugin install \git://github.com/aslakhellesoy/cucumber.git \git://github.com/brynary/webrat.git \git://github.com/dchelimsky/rspec.git \git://github.com/dchelimsky/rspec-rails.git
$ ruby script/plugin install \git://brandon.local/cucumber \git://brandon.local/webrat \git://brandon.local/rspec \git://brandon.local/rspec-rails
$ gem install term-ansicolor \treetop diff-lcs hpricot
Dependencies
$ ruby script/generate cucumber
Feature: Manage companies In order to keep track of companies A user Should be able to manage companies
Scenario: Create a new company Given I am logged in When I create a new company named Acme Then I should see that a company named Acme exists
features/companies.featuresteps/company_steps.rb
Given "I am logged in" douser = Factory(:user)visits new_session_pathfills_in ‘Login’, :with => user.loginfills_in ‘Password’, :with => user.passwordclicks_button ‘Login’
end
Given == Setup
Given "I am logged in" douser = Factory(:user)visits new_session_pathfills_in ‘Login’, :with => user.loginfills_in ‘Password’, :with => user.passwordclicks_button ‘Login’
end
factory_girl
Factory.sequence(:email) {|n| "user#{n}@example.com" }Factory.define :user do |user| user.name 'User' user.email { Factory.next(:email) }user.login {|u| u.email }
user.password 'password' user.password_confirmation 'password'end
Given "I am logged in" douser = Factory(:user)visits new_session_pathfills_in 'Login', :with => user.loginfills_in 'Password', :with => user.passwordclicks_button 'Login'
end
webrat
When "I create a new company named $name" do |name| visits new_company_path fills_in 'Name', :with => name clicks_button 'Create'end
When == Change
When "I create a new company named $name" do |name| visits new_company_path fills_in 'Name', :with => name clicks_button 'Create'end
variable
When I create a new company named Acme
When == Change
Then "I should see that a company named $name exists" do |name| response.body.should =~ Regexp.new(name)end
Then == Outcome
Feature: Manage companies In order to keep track of companies A user Should be able to manage companies
Scenario: Create a new company Given I am logged in When I create a new company named Acme Then I should see that a company named Acme exists
3 steps passsed
Scenario: Paging through leads and rejecting Given a company called Apple Corp. And a company called Pear Inc. And a list for Client A And Apple Corp. is a new lead in a list for Client A And Pear Inc. is a new lead in a list for Client A And I am logged in as a staff member When I view the company overview for Apple Corp. And I reject Apple Corp. And I go to the next lead Then I see the company overview for Pear Inc.
Cucumber or RSpec?
Cucumber or RSpec?
BOTH
http://github.com/bmabey/cucumber-tmbundle/
Feature: Cucumber In order to share the love As a presenter I will demonstrate behavior driven development with Cucumber
Scenario: Behavior Driven Development with Cucumber Given a desire for higher quality software And a tool that executes feature documentation written in plain text When you watch this presentation Then you will gain an understanding of behavior driven development And see examples of behavior driven development with cucumber And be equipped to integrate Cucumber into your development process
6 steps passed
@bkeepers
brandoncollectiveidea
github.com/
opensoul.orgsessions.collectiveidea.com