SlideShare a Scribd company logo
1 of 43
Download to read offline
How I Roll:
A Cucumber/git
  Workflow
 Matt Buck, Capital Thought
We make




Capital Thought

                        I work for
Agenda

• Creating topic branches in git
• Outside-In model of Rails development
• Merging topic branches
• BONUS ROUND: Getting non-technical
  stakeholders involved
$ issue list
    3. Administrators should be able to manage Users
    4. Access should be restricted by Role
    6. Users should be able to edit account settings
    7. Administrators should be able to import Contacts
   13. Authors should be able to manage Posts
   14. Authors should be able to register
$ issue list
    3. Administrators should be able to manage Users
    4. Access should be restricted by Role
    6. Users should be able to edit account settings
    7. Administrators should be able to import Contacts
   13. Authors should be able to manage Posts
   14. Authors should be able to register
$ git checkout -b
13_authors_manage_posts
Outside-in Rails development
• Write a scenario
• Execute the scenario
• Write a step definition
• red/green/refactor View
• red/green/refactor Controller
  • ensure the proper instance variables are
    assigned

•   red/green/refactor Models

    •   ensure they provide methods needed by View
        and Controller
•   Write a step definition
•   red/green/refactor View
•   red/green/refactor Controller
•   red/green/refactor Model
Feature: author manages posts
  As an author
  I want to be able to manage the posts on my blog
  So that my audience can read my content

  Background:
    Given I am logged in as the following active author account:
      | Name | Email address    | Password | Phone number | Fax number   |
      | John | john@myvenue.com | pass     | 555-555-1212 | 555-555-1213 |

  Scenario: Author adds a new post
    When I am on the create post page for John
    When I fill in the form with the following values:
      | Title      | Body         |
      | First post | Hello, blog! |
    And I press "Add post"
    Then I should be on the show post page for "First post"
    And I should see "Your post has been added."
    And I should see "First post"
    And I should see "Hello, blog!"
    And there should be a new post with the title "First post"
Outside-in Rails development
• Write a scenario
• Execute the scenario
• Write a step definition
• red/green/refactor View
• red/green/refactor Controller
  • ensure the proper instance variables are
    assigned

•   red/green/refactor Models

    •   ensure they provide methods needed by View
        and Controller
Feature: author manages posts
  As an author
  I want to be able to manage the posts on my blog
  So that my audience can read my content

 Background:
   Given I am logged in as the following active author account:
     | Name | Email address    | Password | Phone number | Fax number   |
     | John | john@myvenue.com | pass     | 555-555-1212 | 555-555-1213 |

 Scenario: Author adds a new post
   When I am on the create post page for John
   When I fill in the form with the following values:
     | Title      | Body          |
     | First post | Hello, blog! |
   And I press "Add post"
   Then I should be on the show post page for "First post"
   And I should see "Your post has been added."
   And I should see "First post"
   And I should see "Hello, blog!"
   And there should be a new post with the title "First post"
features/env/paths.rb

when /the create post page for (.*)$/
  author = Author.find_by_name($1)
  new_author_post_path(author)
Feature: author manages posts
  As an author
  I want to be able to manage the posts on my blog
  So that my audience can read my content

 Background:
   Given I am logged in as the following active author account:
     | Name | Email address    | Password | Phone number | Fax number   |
     | John | john@myvenue.com | pass     | 555-555-1212 | 555-555-1213 |

 Scenario: Author adds a new post
   When I am on the create post page for John
   When I fill in the form with the following values:
     | Title      | Body          |
     | First post | Hello, blog! |
   And I press "Add post"
   Then I should be on the show post page for "First post"
   And I should see "Your post has been added."
   And I should see "First post"
   And I should see "Hello, blog!"
   And there should be a new post with the title "First post"
Outside-in Rails development
• Write a scenario
• Execute the scenario
• Write a step definition
• red/green/refactor View
• red/green/refactor Controller
  • ensure the proper instance variables are
    assigned

•   red/green/refactor Models

    •   ensure they provide methods needed by View
        and Controller
spec/views/posts/new.html.haml_spec.rb

describe "/posts/new.html.haml" do
  before(:each) do
    assigns[:post] = Factory.build :post
    @author = Factory.create :author
    assigns[:author] = @author
  end

  it "should render new form" do
    render "/events/new.html.haml"
    response.should have_tag("form[action=?][method=post]",
author_posts_path(@author))
  end
end

app/views/posts/new.html.haml

%h1 New post

- form_for([@author, @post]) do |f|
  = render :partial => "form", :locals => {:f => f}

  %p= f.submit "Add Post"
Feature: author manages posts
  As an author
  I want to be able to manage the posts on my blog
  So that my audience can read my content

 Background:
   Given I am logged in as the following active author account:
     | Name | Email address    | Password | Phone number | Fax number   |
     | John | john@myvenue.com | pass     | 555-555-1212 | 555-555-1213 |

 Scenario: Author adds a new post
   When I am on the create post page for John
   When I fill in the form with the following values:
     | Title      | Body          |
     | First post | Hello, blog! |
   And I press "Add post"
   Then I should be on the show post page for "First post"
   And I should see "Your post has been added."
   And I should see "First post"
   And I should see "Hello, blog!"
   And there should be a new post with the title "First post"
Outside-in Rails development
• Write a scenario
• Execute the scenario
• Write a step definition
• red/green/refactor View
• red/green/refactor Controller
  • ensure the proper instance variables
    are assigned

•   red/green/refactor Models

    •   ensure they provide methods needed by View
        and Controller
spec/controllers/posts_controller_spec.rb

describe "responding to GET new" do
  def do_get(params = {})
    stub_author
    get :new, {:author_id => @author}
  end

  it "should expose a new post as @post" do
    post = Factory.build(:post)
    Post.should_receive(:new).and_return(post)
    do_get
    assigns[:post].should equal(post)
  end
end

app/controllers/posts_controller.rb

def new
  @post = Post.new(params[:post])

  respond_to do |format|
    format.html # new.html.erb
    format.xml { render :xml => @post }
  end
end
Feature: author manages posts
  As an author
  I want to be able to manage the posts on my blog
  So that my audience can read my content

 Background:
   Given I am logged in as the following active author account:
     | Name | Email address    | Password | Phone number | Fax number   |
     | John | john@myvenue.com | pass     | 555-555-1212 | 555-555-1213 |

 Scenario: Author adds a new post
   When I am on the create post page for John
   When I fill in the form with the following values:
     | Title      | Body          |
     | First post | Hello, blog! |
   And I press "Add post"
   Then I should be on the show post page for "First post"
   And I should see "Your post has been added."
   And I should see "First post"
   And I should see "Hello, blog!"
   And there should be a new post with the title "First post"
features/env/paths.rb

when /the (create|show) post page for (.*)$/
  author = Author.find_by_name($2)‚Ä®

  case $1
  when /create/
    new_author_post_path(author)
  when /show/
    autho_post_path(author)
Feature: author manages posts
  As an author
  I want to be able to manage the posts on my blog
  So that my audience can read my content

 Background:
   Given I am logged in as the following active author account:
     | Name | Email address    | Password | Phone number | Fax number   |
     | John | john@myvenue.com | pass     | 555-555-1212 | 555-555-1213 |

 Scenario: Author adds a new post
   When I am on the create post page for John
   When I fill in the form with the following values:
     | Title      | Body          |
     | First post | Hello, blog! |
   And I press "Add post"
   Then I should be on the show post page for "First post"
   And I should see "Your post has been added."
   And I should see "First post"
   And I should see "Hello, blog!"
   And there should be a new post with the title "First post"
spec/controllers/posts_controller_spec.rb

it "should redirect to the created post" do
  Post.stub!(:new).and_return(@new_post)
  post :create, :post => {}
  response.should redirect_to(author_post_url(@author, @new_post))
end

app/controllers/posts_controller.rb

# POST /posts
# POST /posts.xml
def create
  @post = @author.posts.new(params[:post])

  respond_to do |format|
    if @post.save
      flash[:notice] = 'Post was successfully created.'
      redirect_to author_post_url(@author, @post)
    else
      render :action => "new"
    end
  end
end
Feature: author manages posts
  As an author
  I want to be able to manage the posts on my blog
  So that my audience can read my content

 Background:
   Given I am logged in as the following active author account:
     | Name | Email address    | Password | Phone number | Fax number   |
     | John | john@myvenue.com | pass     | 555-555-1212 | 555-555-1213 |

 Scenario: Author adds a new post
   When I am on the post creation page for John
   When I fill in the form with the following values:
     | Title       | Body          |
     | First post! | Hello, blog! |
   And I press "Add post"
   Then I should be on the show post page for "First post"
   And I should see "Your post has been added."
   And I should see "First post"
   And I should see "Hello, blog!"
   And there should be a new post with the title "First post"
Fast forward...
Feature: author manages posts
  As an author
  I want to be able to manage the posts on my blog
  So that my audience can read my content

 Background:
   Given I am logged in as the following active author account:
     | Name | Email address    | Password | Phone number | Fax number   |
     | John | john@myvenue.com | pass     | 555-555-1212 | 555-555-1213 |

 Scenario: Author adds a new post
   When I am on the post creation page for John
   When I fill in the form with the following values:
     | Title      | Body          |
     | First post | Hello, blog! |
   And I press "Add post"
   Then I should be on the show post page for “First Post”
   And I should see "Your post has been added."
   And I should see "First post"
   And I should see "Hello, blog!"
   And there should be a new post with the title "First post"
Feature: author manages posts
  As an author
  I want to be able to manage the posts on my blog
  So that my audience can read my content

 Background:
   Given I am logged in as the following active author account:
     | Name | Email address    | Password | Phone number | Fax number   |
     | John | john@myvenue.com | pass     | 555-555-1212 | 555-555-1213 |

 Scenario: Author adds a new post
   When I am on the post creation page for John
   When I fill in the form with the following values:
     | Title      | Body          |
     | First post | Hello, blog! |
   And I press "Add post"
   Then I should be on the show post page for “First Post”
   And I should see "Your post has been added."
   And I should see "First post"
   And I should see "Hello, blog!"
   And I should see "This post contains 22 characters"
   And there should be a new post with the title "First post"
spec/views/posts/show.html.haml_spec.rb

describe "/posts/show.html.haml" do
  before(:each) do
    @post   = Factory.create :post
    @author = Factory.create :author
    assigns[:author] = @author
    assigns[:post]   = @post
    @post.stub!(:total_length).and_return(24)
  end

  it "should display the length of the post in characters" do
    render "/events/show.html.haml"
    response.should have_tag("span#length", :text => 24)
  end
end

app/views/posts/new.html.haml

%h1= @post.title

%span#length= @post.total_length
spec/models/post_spec.rb

it "should return the length of the body and title in characters" do
  post = Post.create :title => "Title", :body => "Body"
  post.total_length.should == 9
end

spec/models/post.rb

def total_length
  title.size + body.size
end
Feature: author manages posts
  As an author
  I want to be able to manage the posts on my blog
  So that my audience can read my content

 Background:
   Given I am logged in as the following active author account:
     | Name | Email address    | Password | Phone number | Fax number   |
     | John | john@myvenue.com | pass     | 555-555-1212 | 555-555-1213 |

 Scenario: Author adds a new post
   When I am on the post creation page for John
   When I fill in the form with the following values:
     | Title      | Body          |
     | First post | Hello, blog! |
   And I press "Add post"
   Then I should be on the show post page for “First Post”
   And I should see "Your post has been added."
   And I should see "First post"
   And I should see "Hello, blog!"
   And I should see "This post contains 22 characters"
   And there should be a new post with the title "First post"
$ git checkout master
$ git merge --squash 13_authors_manage_posts
$ git commit -m “Implemented <...> Closes #13”
$ git checkout master
$ git merge --squash 13_authors_manage_posts
$ git commit -m “Implemented <...> Closes #13”
$ git checkout master
$ git merge 13_authors_manage_posts
Bonus Round
How do we get
     non-technical
stakeholders involved in
   the story creation
        process?
Credits, etc.

• Cucumber roll image: http://www.flickr.com/
  photos/stuart_spivack/464718611/
• Github Issues CLI: http://github.com/jsmits/
  github-cli/tree/master
• The RSpec Book: http://www.pragprog.com/
  titles/achbd/the-rspec-book

More Related Content

What's hot

Enter the app era with ruby on rails (rubyday)
Enter the app era with ruby on rails (rubyday)Enter the app era with ruby on rails (rubyday)
Enter the app era with ruby on rails (rubyday)Matteo Collina
 
How we improved performance at Mixbook
How we improved performance at MixbookHow we improved performance at Mixbook
How we improved performance at MixbookAnton Astashov
 
Enter the app era with ruby on rails
Enter the app era with ruby on railsEnter the app era with ruby on rails
Enter the app era with ruby on railsMatteo Collina
 
Behat, Test Driven Framework for BDD by Jeevan Bhushetty
Behat, Test Driven Framework for BDD by Jeevan BhushettyBehat, Test Driven Framework for BDD by Jeevan Bhushetty
Behat, Test Driven Framework for BDD by Jeevan BhushettyAgile Testing Alliance
 
Rapi::Blog talk - TPC 2017
Rapi::Blog talk - TPC 2017Rapi::Blog talk - TPC 2017
Rapi::Blog talk - TPC 2017Henry Van Styn
 
Outside-in Development with Cucumber and Rspec
Outside-in Development with Cucumber and RspecOutside-in Development with Cucumber and Rspec
Outside-in Development with Cucumber and RspecJoseph Wilk
 
Teaming up WordPress API with Backbone.js in Titanium
Teaming up WordPress API with Backbone.js in TitaniumTeaming up WordPress API with Backbone.js in Titanium
Teaming up WordPress API with Backbone.js in TitaniumJeroen van Dijk
 
A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...
A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...
A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...Ho Chi Minh City Software Testing Club
 
Behavior Driven Development - How To Start with Behat
Behavior Driven Development - How To Start with BehatBehavior Driven Development - How To Start with Behat
Behavior Driven Development - How To Start with Behatimoneytech
 
Ruby conf 2011, Create your own rails framework
Ruby conf 2011, Create your own rails frameworkRuby conf 2011, Create your own rails framework
Ruby conf 2011, Create your own rails frameworkPankaj Bhageria
 
RubyConf Bangladesh 2017 - Elixir for Rubyists
RubyConf Bangladesh 2017 - Elixir for RubyistsRubyConf Bangladesh 2017 - Elixir for Rubyists
RubyConf Bangladesh 2017 - Elixir for RubyistsRuby Bangladesh
 
RapidApp - YAPC::NA 2014
RapidApp - YAPC::NA 2014RapidApp - YAPC::NA 2014
RapidApp - YAPC::NA 2014Henry Van Styn
 
Testing ASP.net Web Applications using Ruby
Testing ASP.net Web Applications using RubyTesting ASP.net Web Applications using Ruby
Testing ASP.net Web Applications using RubyBen Hall
 
Building WordPress Client Side Applications with WP and WP-API - #wcmia
Building WordPress Client Side Applications with WP and WP-API - #wcmiaBuilding WordPress Client Side Applications with WP and WP-API - #wcmia
Building WordPress Client Side Applications with WP and WP-API - #wcmiaRoy Sivan
 
Action View Form Helpers - 1, Season 2
Action View Form Helpers - 1, Season 2Action View Form Helpers - 1, Season 2
Action View Form Helpers - 1, Season 2RORLAB
 
How to build Client Side Applications with WordPress and WP-API | #wcmia
How to build Client Side Applications with WordPress and WP-API | #wcmiaHow to build Client Side Applications with WordPress and WP-API | #wcmia
How to build Client Side Applications with WordPress and WP-API | #wcmiaRoy Sivan
 
Rails 2.3 and Rack - NHRuby Feb 2009
Rails 2.3 and Rack - NHRuby Feb 2009Rails 2.3 and Rack - NHRuby Feb 2009
Rails 2.3 and Rack - NHRuby Feb 2009bturnbull
 
Associations & JavaScript
Associations & JavaScriptAssociations & JavaScript
Associations & JavaScriptJoost Elfering
 
Using Angular with Rails
Using Angular with RailsUsing Angular with Rails
Using Angular with RailsJamie Davidson
 

What's hot (20)

Enter the app era with ruby on rails (rubyday)
Enter the app era with ruby on rails (rubyday)Enter the app era with ruby on rails (rubyday)
Enter the app era with ruby on rails (rubyday)
 
BDD with cucumber
BDD with cucumberBDD with cucumber
BDD with cucumber
 
How we improved performance at Mixbook
How we improved performance at MixbookHow we improved performance at Mixbook
How we improved performance at Mixbook
 
Enter the app era with ruby on rails
Enter the app era with ruby on railsEnter the app era with ruby on rails
Enter the app era with ruby on rails
 
Behat, Test Driven Framework for BDD by Jeevan Bhushetty
Behat, Test Driven Framework for BDD by Jeevan BhushettyBehat, Test Driven Framework for BDD by Jeevan Bhushetty
Behat, Test Driven Framework for BDD by Jeevan Bhushetty
 
Rapi::Blog talk - TPC 2017
Rapi::Blog talk - TPC 2017Rapi::Blog talk - TPC 2017
Rapi::Blog talk - TPC 2017
 
Outside-in Development with Cucumber and Rspec
Outside-in Development with Cucumber and RspecOutside-in Development with Cucumber and Rspec
Outside-in Development with Cucumber and Rspec
 
Teaming up WordPress API with Backbone.js in Titanium
Teaming up WordPress API with Backbone.js in TitaniumTeaming up WordPress API with Backbone.js in Titanium
Teaming up WordPress API with Backbone.js in Titanium
 
A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...
A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...
A Universal Automation Framework based on BDD Cucumber and Ruby on Rails - Ph...
 
Behavior Driven Development - How To Start with Behat
Behavior Driven Development - How To Start with BehatBehavior Driven Development - How To Start with Behat
Behavior Driven Development - How To Start with Behat
 
Ruby conf 2011, Create your own rails framework
Ruby conf 2011, Create your own rails frameworkRuby conf 2011, Create your own rails framework
Ruby conf 2011, Create your own rails framework
 
RubyConf Bangladesh 2017 - Elixir for Rubyists
RubyConf Bangladesh 2017 - Elixir for RubyistsRubyConf Bangladesh 2017 - Elixir for Rubyists
RubyConf Bangladesh 2017 - Elixir for Rubyists
 
RapidApp - YAPC::NA 2014
RapidApp - YAPC::NA 2014RapidApp - YAPC::NA 2014
RapidApp - YAPC::NA 2014
 
Testing ASP.net Web Applications using Ruby
Testing ASP.net Web Applications using RubyTesting ASP.net Web Applications using Ruby
Testing ASP.net Web Applications using Ruby
 
Building WordPress Client Side Applications with WP and WP-API - #wcmia
Building WordPress Client Side Applications with WP and WP-API - #wcmiaBuilding WordPress Client Side Applications with WP and WP-API - #wcmia
Building WordPress Client Side Applications with WP and WP-API - #wcmia
 
Action View Form Helpers - 1, Season 2
Action View Form Helpers - 1, Season 2Action View Form Helpers - 1, Season 2
Action View Form Helpers - 1, Season 2
 
How to build Client Side Applications with WordPress and WP-API | #wcmia
How to build Client Side Applications with WordPress and WP-API | #wcmiaHow to build Client Side Applications with WordPress and WP-API | #wcmia
How to build Client Side Applications with WordPress and WP-API | #wcmia
 
Rails 2.3 and Rack - NHRuby Feb 2009
Rails 2.3 and Rack - NHRuby Feb 2009Rails 2.3 and Rack - NHRuby Feb 2009
Rails 2.3 and Rack - NHRuby Feb 2009
 
Associations & JavaScript
Associations & JavaScriptAssociations & JavaScript
Associations & JavaScript
 
Using Angular with Rails
Using Angular with RailsUsing Angular with Rails
Using Angular with Rails
 

Similar to How I Roll - A Cucumber/git workflow

Transformando os pepinos do cliente no código de testes da sua aplicação
Transformando os pepinos do cliente no código de testes da sua aplicaçãoTransformando os pepinos do cliente no código de testes da sua aplicação
Transformando os pepinos do cliente no código de testes da sua aplicaçãoRodrigo Urubatan
 
Grand Rapids PHP Meetup: Behavioral Driven Development with Behat
Grand Rapids PHP Meetup: Behavioral Driven Development with BehatGrand Rapids PHP Meetup: Behavioral Driven Development with Behat
Grand Rapids PHP Meetup: Behavioral Driven Development with BehatRyan Weaver
 
Using php to design a guestbook website tutorial
Using php to design a guestbook website tutorialUsing php to design a guestbook website tutorial
Using php to design a guestbook website tutorialphillyquin
 
Custom Post Type - Create and Display
Custom Post Type - Create and DisplayCustom Post Type - Create and Display
Custom Post Type - Create and DisplayJan Wilson
 
Getting Answers to Your Testing Questions
Getting Answers to Your Testing QuestionsGetting Answers to Your Testing Questions
Getting Answers to Your Testing Questionsjasnow
 
Word blogging feature
Word blogging featureWord blogging feature
Word blogging featureAlan Haller
 
Controller Testing: You're Doing It Wrong
Controller Testing: You're Doing It WrongController Testing: You're Doing It Wrong
Controller Testing: You're Doing It Wrongjohnnygroundwork
 
Simple Usability Tweaks for Your WordPress Theme
Simple Usability Tweaks for Your WordPress ThemeSimple Usability Tweaks for Your WordPress Theme
Simple Usability Tweaks for Your WordPress ThemeGraham Armfield
 
Testing web APIs
Testing web APIsTesting web APIs
Testing web APIsFDConf
 
How To Set Up A Blog
How To  Set  Up A  BlogHow To  Set  Up A  Blog
How To Set Up A BlogBobby Norris
 
Integration Test With Cucumber And Webrat
Integration Test With Cucumber And WebratIntegration Test With Cucumber And Webrat
Integration Test With Cucumber And WebratKang-min Liu
 
Behavior Driven Development with Cucumber
Behavior Driven Development with CucumberBehavior Driven Development with Cucumber
Behavior Driven Development with CucumberBrandon Keepers
 
Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)
Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)
Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)Cogapp
 
Content-Driven WordPress Development - WordCamp Omaha 2014
Content-Driven WordPress Development - WordCamp Omaha 2014Content-Driven WordPress Development - WordCamp Omaha 2014
Content-Driven WordPress Development - WordCamp Omaha 2014Stephanie Eckles
 
Getting started-with-oracle-so a-i
Getting started-with-oracle-so a-iGetting started-with-oracle-so a-i
Getting started-with-oracle-so a-iAmit Sharma
 
Getting started-with-oracle-so a-i
Getting started-with-oracle-so a-iGetting started-with-oracle-so a-i
Getting started-with-oracle-so a-iAmit Sharma
 
Passo a Passo para criar uma aplicação Móvel Híbrida
Passo a Passo para criar uma aplicação Móvel HíbridaPasso a Passo para criar uma aplicação Móvel Híbrida
Passo a Passo para criar uma aplicação Móvel HíbridaJuliano Martins
 
Part 1; CSS and placing images on the page: The following files are located i...
Part 1; CSS and placing images on the page: The following files are located i...Part 1; CSS and placing images on the page: The following files are located i...
Part 1; CSS and placing images on the page: The following files are located i...hwbloom15
 

Similar to How I Roll - A Cucumber/git workflow (20)

Transformando os pepinos do cliente no código de testes da sua aplicação
Transformando os pepinos do cliente no código de testes da sua aplicaçãoTransformando os pepinos do cliente no código de testes da sua aplicação
Transformando os pepinos do cliente no código de testes da sua aplicação
 
Cucumber
CucumberCucumber
Cucumber
 
Grand Rapids PHP Meetup: Behavioral Driven Development with Behat
Grand Rapids PHP Meetup: Behavioral Driven Development with BehatGrand Rapids PHP Meetup: Behavioral Driven Development with Behat
Grand Rapids PHP Meetup: Behavioral Driven Development with Behat
 
Using php to design a guestbook website tutorial
Using php to design a guestbook website tutorialUsing php to design a guestbook website tutorial
Using php to design a guestbook website tutorial
 
Custom Post Type - Create and Display
Custom Post Type - Create and DisplayCustom Post Type - Create and Display
Custom Post Type - Create and Display
 
Getting Answers to Your Testing Questions
Getting Answers to Your Testing QuestionsGetting Answers to Your Testing Questions
Getting Answers to Your Testing Questions
 
Word blogging feature
Word blogging featureWord blogging feature
Word blogging feature
 
Controller Testing: You're Doing It Wrong
Controller Testing: You're Doing It WrongController Testing: You're Doing It Wrong
Controller Testing: You're Doing It Wrong
 
Simple Usability Tweaks for Your WordPress Theme
Simple Usability Tweaks for Your WordPress ThemeSimple Usability Tweaks for Your WordPress Theme
Simple Usability Tweaks for Your WordPress Theme
 
Cucumber & BDD
Cucumber & BDDCucumber & BDD
Cucumber & BDD
 
Testing web APIs
Testing web APIsTesting web APIs
Testing web APIs
 
How To Set Up A Blog
How To  Set  Up A  BlogHow To  Set  Up A  Blog
How To Set Up A Blog
 
Integration Test With Cucumber And Webrat
Integration Test With Cucumber And WebratIntegration Test With Cucumber And Webrat
Integration Test With Cucumber And Webrat
 
Behavior Driven Development with Cucumber
Behavior Driven Development with CucumberBehavior Driven Development with Cucumber
Behavior Driven Development with Cucumber
 
Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)
Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)
Test-driven Development with Drupal and Codeception (DrupalCamp Brighton)
 
Content-Driven WordPress Development - WordCamp Omaha 2014
Content-Driven WordPress Development - WordCamp Omaha 2014Content-Driven WordPress Development - WordCamp Omaha 2014
Content-Driven WordPress Development - WordCamp Omaha 2014
 
Getting started-with-oracle-so a-i
Getting started-with-oracle-so a-iGetting started-with-oracle-so a-i
Getting started-with-oracle-so a-i
 
Getting started-with-oracle-so a-i
Getting started-with-oracle-so a-iGetting started-with-oracle-so a-i
Getting started-with-oracle-so a-i
 
Passo a Passo para criar uma aplicação Móvel Híbrida
Passo a Passo para criar uma aplicação Móvel HíbridaPasso a Passo para criar uma aplicação Móvel Híbrida
Passo a Passo para criar uma aplicação Móvel Híbrida
 
Part 1; CSS and placing images on the page: The following files are located i...
Part 1; CSS and placing images on the page: The following files are located i...Part 1; CSS and placing images on the page: The following files are located i...
Part 1; CSS and placing images on the page: The following files are located i...
 

Recently uploaded

Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 

Recently uploaded (20)

Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 

How I Roll - A Cucumber/git workflow

  • 1. How I Roll: A Cucumber/git Workflow Matt Buck, Capital Thought
  • 3. Agenda • Creating topic branches in git • Outside-In model of Rails development • Merging topic branches • BONUS ROUND: Getting non-technical stakeholders involved
  • 4. $ issue list 3. Administrators should be able to manage Users 4. Access should be restricted by Role 6. Users should be able to edit account settings 7. Administrators should be able to import Contacts 13. Authors should be able to manage Posts 14. Authors should be able to register
  • 5. $ issue list 3. Administrators should be able to manage Users 4. Access should be restricted by Role 6. Users should be able to edit account settings 7. Administrators should be able to import Contacts 13. Authors should be able to manage Posts 14. Authors should be able to register
  • 6. $ git checkout -b 13_authors_manage_posts
  • 7. Outside-in Rails development • Write a scenario • Execute the scenario • Write a step definition • red/green/refactor View • red/green/refactor Controller • ensure the proper instance variables are assigned • red/green/refactor Models • ensure they provide methods needed by View and Controller
  • 8.
  • 9. Write a step definition
  • 10. red/green/refactor View
  • 11. red/green/refactor Controller
  • 12. red/green/refactor Model
  • 13. Feature: author manages posts As an author I want to be able to manage the posts on my blog So that my audience can read my content Background: Given I am logged in as the following active author account: | Name | Email address | Password | Phone number | Fax number | | John | john@myvenue.com | pass | 555-555-1212 | 555-555-1213 | Scenario: Author adds a new post When I am on the create post page for John When I fill in the form with the following values: | Title | Body | | First post | Hello, blog! | And I press "Add post" Then I should be on the show post page for "First post" And I should see "Your post has been added." And I should see "First post" And I should see "Hello, blog!" And there should be a new post with the title "First post"
  • 14. Outside-in Rails development • Write a scenario • Execute the scenario • Write a step definition • red/green/refactor View • red/green/refactor Controller • ensure the proper instance variables are assigned • red/green/refactor Models • ensure they provide methods needed by View and Controller
  • 15. Feature: author manages posts As an author I want to be able to manage the posts on my blog So that my audience can read my content Background: Given I am logged in as the following active author account: | Name | Email address | Password | Phone number | Fax number | | John | john@myvenue.com | pass | 555-555-1212 | 555-555-1213 | Scenario: Author adds a new post When I am on the create post page for John When I fill in the form with the following values: | Title | Body | | First post | Hello, blog! | And I press "Add post" Then I should be on the show post page for "First post" And I should see "Your post has been added." And I should see "First post" And I should see "Hello, blog!" And there should be a new post with the title "First post"
  • 16. features/env/paths.rb when /the create post page for (.*)$/ author = Author.find_by_name($1) new_author_post_path(author)
  • 17. Feature: author manages posts As an author I want to be able to manage the posts on my blog So that my audience can read my content Background: Given I am logged in as the following active author account: | Name | Email address | Password | Phone number | Fax number | | John | john@myvenue.com | pass | 555-555-1212 | 555-555-1213 | Scenario: Author adds a new post When I am on the create post page for John When I fill in the form with the following values: | Title | Body | | First post | Hello, blog! | And I press "Add post" Then I should be on the show post page for "First post" And I should see "Your post has been added." And I should see "First post" And I should see "Hello, blog!" And there should be a new post with the title "First post"
  • 18. Outside-in Rails development • Write a scenario • Execute the scenario • Write a step definition • red/green/refactor View • red/green/refactor Controller • ensure the proper instance variables are assigned • red/green/refactor Models • ensure they provide methods needed by View and Controller
  • 19. spec/views/posts/new.html.haml_spec.rb describe "/posts/new.html.haml" do before(:each) do assigns[:post] = Factory.build :post @author = Factory.create :author assigns[:author] = @author end it "should render new form" do render "/events/new.html.haml" response.should have_tag("form[action=?][method=post]", author_posts_path(@author)) end end app/views/posts/new.html.haml %h1 New post - form_for([@author, @post]) do |f| = render :partial => "form", :locals => {:f => f} %p= f.submit "Add Post"
  • 20. Feature: author manages posts As an author I want to be able to manage the posts on my blog So that my audience can read my content Background: Given I am logged in as the following active author account: | Name | Email address | Password | Phone number | Fax number | | John | john@myvenue.com | pass | 555-555-1212 | 555-555-1213 | Scenario: Author adds a new post When I am on the create post page for John When I fill in the form with the following values: | Title | Body | | First post | Hello, blog! | And I press "Add post" Then I should be on the show post page for "First post" And I should see "Your post has been added." And I should see "First post" And I should see "Hello, blog!" And there should be a new post with the title "First post"
  • 21. Outside-in Rails development • Write a scenario • Execute the scenario • Write a step definition • red/green/refactor View • red/green/refactor Controller • ensure the proper instance variables are assigned • red/green/refactor Models • ensure they provide methods needed by View and Controller
  • 22. spec/controllers/posts_controller_spec.rb describe "responding to GET new" do def do_get(params = {}) stub_author get :new, {:author_id => @author} end it "should expose a new post as @post" do post = Factory.build(:post) Post.should_receive(:new).and_return(post) do_get assigns[:post].should equal(post) end end app/controllers/posts_controller.rb def new @post = Post.new(params[:post]) respond_to do |format| format.html # new.html.erb format.xml { render :xml => @post } end end
  • 23. Feature: author manages posts As an author I want to be able to manage the posts on my blog So that my audience can read my content Background: Given I am logged in as the following active author account: | Name | Email address | Password | Phone number | Fax number | | John | john@myvenue.com | pass | 555-555-1212 | 555-555-1213 | Scenario: Author adds a new post When I am on the create post page for John When I fill in the form with the following values: | Title | Body | | First post | Hello, blog! | And I press "Add post" Then I should be on the show post page for "First post" And I should see "Your post has been added." And I should see "First post" And I should see "Hello, blog!" And there should be a new post with the title "First post"
  • 24. features/env/paths.rb when /the (create|show) post page for (.*)$/ author = Author.find_by_name($2)‚Ä® case $1 when /create/ new_author_post_path(author) when /show/ autho_post_path(author)
  • 25. Feature: author manages posts As an author I want to be able to manage the posts on my blog So that my audience can read my content Background: Given I am logged in as the following active author account: | Name | Email address | Password | Phone number | Fax number | | John | john@myvenue.com | pass | 555-555-1212 | 555-555-1213 | Scenario: Author adds a new post When I am on the create post page for John When I fill in the form with the following values: | Title | Body | | First post | Hello, blog! | And I press "Add post" Then I should be on the show post page for "First post" And I should see "Your post has been added." And I should see "First post" And I should see "Hello, blog!" And there should be a new post with the title "First post"
  • 26. spec/controllers/posts_controller_spec.rb it "should redirect to the created post" do Post.stub!(:new).and_return(@new_post) post :create, :post => {} response.should redirect_to(author_post_url(@author, @new_post)) end app/controllers/posts_controller.rb # POST /posts # POST /posts.xml def create @post = @author.posts.new(params[:post]) respond_to do |format| if @post.save flash[:notice] = 'Post was successfully created.' redirect_to author_post_url(@author, @post) else render :action => "new" end end end
  • 27. Feature: author manages posts As an author I want to be able to manage the posts on my blog So that my audience can read my content Background: Given I am logged in as the following active author account: | Name | Email address | Password | Phone number | Fax number | | John | john@myvenue.com | pass | 555-555-1212 | 555-555-1213 | Scenario: Author adds a new post When I am on the post creation page for John When I fill in the form with the following values: | Title | Body | | First post! | Hello, blog! | And I press "Add post" Then I should be on the show post page for "First post" And I should see "Your post has been added." And I should see "First post" And I should see "Hello, blog!" And there should be a new post with the title "First post"
  • 29. Feature: author manages posts As an author I want to be able to manage the posts on my blog So that my audience can read my content Background: Given I am logged in as the following active author account: | Name | Email address | Password | Phone number | Fax number | | John | john@myvenue.com | pass | 555-555-1212 | 555-555-1213 | Scenario: Author adds a new post When I am on the post creation page for John When I fill in the form with the following values: | Title | Body | | First post | Hello, blog! | And I press "Add post" Then I should be on the show post page for “First Post” And I should see "Your post has been added." And I should see "First post" And I should see "Hello, blog!" And there should be a new post with the title "First post"
  • 30. Feature: author manages posts As an author I want to be able to manage the posts on my blog So that my audience can read my content Background: Given I am logged in as the following active author account: | Name | Email address | Password | Phone number | Fax number | | John | john@myvenue.com | pass | 555-555-1212 | 555-555-1213 | Scenario: Author adds a new post When I am on the post creation page for John When I fill in the form with the following values: | Title | Body | | First post | Hello, blog! | And I press "Add post" Then I should be on the show post page for “First Post” And I should see "Your post has been added." And I should see "First post" And I should see "Hello, blog!" And I should see "This post contains 22 characters" And there should be a new post with the title "First post"
  • 31. spec/views/posts/show.html.haml_spec.rb describe "/posts/show.html.haml" do before(:each) do @post = Factory.create :post @author = Factory.create :author assigns[:author] = @author assigns[:post] = @post @post.stub!(:total_length).and_return(24) end it "should display the length of the post in characters" do render "/events/show.html.haml" response.should have_tag("span#length", :text => 24) end end app/views/posts/new.html.haml %h1= @post.title %span#length= @post.total_length
  • 32. spec/models/post_spec.rb it "should return the length of the body and title in characters" do post = Post.create :title => "Title", :body => "Body" post.total_length.should == 9 end spec/models/post.rb def total_length title.size + body.size end
  • 33. Feature: author manages posts As an author I want to be able to manage the posts on my blog So that my audience can read my content Background: Given I am logged in as the following active author account: | Name | Email address | Password | Phone number | Fax number | | John | john@myvenue.com | pass | 555-555-1212 | 555-555-1213 | Scenario: Author adds a new post When I am on the post creation page for John When I fill in the form with the following values: | Title | Body | | First post | Hello, blog! | And I press "Add post" Then I should be on the show post page for “First Post” And I should see "Your post has been added." And I should see "First post" And I should see "Hello, blog!" And I should see "This post contains 22 characters" And there should be a new post with the title "First post"
  • 34. $ git checkout master $ git merge --squash 13_authors_manage_posts $ git commit -m “Implemented <...> Closes #13”
  • 35.
  • 36. $ git checkout master $ git merge --squash 13_authors_manage_posts $ git commit -m “Implemented <...> Closes #13”
  • 37. $ git checkout master $ git merge 13_authors_manage_posts
  • 38.
  • 40. How do we get non-technical stakeholders involved in the story creation process?
  • 41.
  • 42.
  • 43. Credits, etc. • Cucumber roll image: http://www.flickr.com/ photos/stuart_spivack/464718611/ • Github Issues CLI: http://github.com/jsmits/ github-cli/tree/master • The RSpec Book: http://www.pragprog.com/ titles/achbd/the-rspec-book