behavior driven development with cucumber

44
Cucumber http://flickr.com/photos/nickatkins/527421404/ Brandon Keepers Collective idea http://opensoul.org with Behavior Driven Development

Upload: brandon-keepers

Post on 01-Dec-2014

44.271 views

Category:

Technology


3 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Behavior Driven Development with Cucumber

Cucumber

http://flickr.com/photos/nickatkins/527421404/

Brandon Keepers ● Collective idea ● http://opensoul.org

withBehavior Driven Development

Page 2: Behavior Driven Development with Cucumber

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

Page 3: Behavior Driven Development with Cucumber

Quality

Page 4: Behavior Driven Development with Cucumber

1Qualitymeets requirements

Page 5: Behavior Driven Development with Cucumber

Developer

Client

Language

Page 6: Behavior Driven Development with Cucumber

Developer

Client

Stories

Page 7: Behavior Driven Development with Cucumber
Page 8: Behavior Driven Development with Cucumber

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

Page 9: Behavior Driven Development with Cucumber

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

Page 10: Behavior Driven Development with Cucumber

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

Page 11: Behavior Driven Development with Cucumber

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

Page 12: Behavior Driven Development with Cucumber

2Qualityworks as expected

Page 13: Behavior Driven Development with Cucumber

Test Driven

Page 14: Behavior Driven Development with Cucumber

Behavior Driven

Page 15: Behavior Driven Development with Cucumber
Page 16: Behavior Driven Development with Cucumber

Verify

Page 17: Behavior Driven Development with Cucumber

Confidence

Page 18: Behavior Driven Development with Cucumber

Design

Page 19: Behavior Driven Development with Cucumber

Behavior

Page 20: Behavior Driven Development with Cucumber

Testing

Specifying

Page 21: Behavior Driven Development with Cucumber

Cucumber

http://flickr.com/photos/nickatkins/527421404/

Page 22: Behavior Driven Development with Cucumber

rbehave

rSpec Story Runner

Cucumber

Page 23: Behavior Driven Development with Cucumber

http://github.com/aslakhellesoy/cucumber

Page 24: Behavior Driven Development with Cucumber

$ gem install cucumber

Page 25: Behavior Driven Development with Cucumber

require 'rubygems'require 'cucumber/rake/task' Cucumber::Rake::Task.new

Rakefile

Page 26: Behavior Driven Development with Cucumber

$ rake features

Page 27: Behavior Driven Development with Cucumber

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

Page 28: Behavior Driven Development with Cucumber

$ gem install term-ansicolor \treetop diff-lcs hpricot

Dependencies

Page 29: Behavior Driven Development with Cucumber

$ ruby script/generate cucumber

Page 30: Behavior Driven Development with 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

Page 31: Behavior Driven Development with Cucumber

features/companies.featuresteps/company_steps.rb

Page 32: Behavior Driven Development with Cucumber

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

Page 33: Behavior Driven Development with Cucumber

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

Page 34: Behavior Driven Development with Cucumber

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

Page 35: Behavior Driven Development with Cucumber

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

Page 36: Behavior Driven Development with Cucumber

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

Page 37: Behavior Driven Development with Cucumber

Then "I should see that a company named $name exists" do |name| response.body.should =~ Regexp.new(name)end

Then == Outcome

Page 38: Behavior Driven Development with 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

3 steps passsed

Page 39: Behavior Driven Development with Cucumber

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.

Page 40: Behavior Driven Development with Cucumber

Cucumber or RSpec?

Page 41: Behavior Driven Development with Cucumber

Cucumber or RSpec?

BOTH

Page 42: Behavior Driven Development with Cucumber

http://github.com/bmabey/cucumber-tmbundle/

Page 43: Behavior Driven Development with Cucumber

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

Page 44: Behavior Driven Development with Cucumber

@bkeepers

brandoncollectiveidea

github.com/

opensoul.orgsessions.collectiveidea.com