Your SlideShare is downloading. ×
How I Roll - A Cucumber/git workflow
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

How I Roll - A Cucumber/git workflow

5,465
views

Published on

Outlines a simple Rails workflow utilizing git, Github Issues, Cucumber, and RSpec. Demonstrates that Cucumber can be used to drive the implementation path.

Outlines a simple Rails workflow utilizing git, Github Issues, Cucumber, and RSpec. Demonstrates that Cucumber can be used to drive the implementation path.

Published in: Technology, Self Improvement

2 Comments
9 Likes
Statistics
Notes
  • I wish there was a video for this, not just the slide show. My major problem is duplication of effort between Cucumber and RSpec. I've got way too much redundancy.

    It appears that you limit Cucumber to views then write the supporting RSpec's to support that. I think I was trying to do too much with Cucumber so I'll give your approach a try and see if I can DRY up my tests.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Great demonstration about the need to innovate company models; how you can represent them succinctly; along with the intent to make advancement initiatives actionable. Superb use of images and obvious to see illustrative samples.
    Sharika
    http://financeadded.com http://traveltreble.com
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total Views
5,465
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
106
Comments
2
Likes
9
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. How I Roll: A Cucumber/git Workflow Matt Buck, Capital Thought
  • 2. We make Capital Thought I work for
  • 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. • Write a step definition
  • 9. • red/green/refactor View
  • 10. • red/green/refactor Controller
  • 11. • red/green/refactor Model
  • 12. 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"
  • 13. 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
  • 14. 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"
  • 15. features/env/paths.rb when /the create post page for (.*)$/ author = Author.find_by_name($1) new_author_post_path(author)
  • 16. 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"
  • 17. 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
  • 18. 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"
  • 19. 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"
  • 20. 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
  • 21. 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
  • 22. 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"
  • 23. 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)
  • 24. 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"
  • 25. 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
  • 26. 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"
  • 27. Fast forward...
  • 28. 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 I should see "This post contains 22 characters" And there should be a new post with the title "First post"
  • 30. 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
  • 31. 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
  • 32. 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"
  • 33. $ git checkout master $ git merge --squash 13_authors_manage_posts $ git commit -m “Implemented <...> Closes #13”
  • 34. $ git checkout master $ git merge --squash 13_authors_manage_posts $ git commit -m “Implemented <...> Closes #13”
  • 35. $ git checkout master $ git merge 13_authors_manage_posts
  • 36. Bonus Round
  • 37. How do we get non-technical stakeholders involved in the story creation process?
  • 38. 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

×