Outside-in Development with Cucumber and Rspec

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    25 Favorites

    Outside-in Development with Cucumber and Rspec - Presentation Transcript

    1. utside in Development Cucumber Rspec Joseph Wilk / http://blog.josephwilk.net
    2. Why are you here?
    3. Why are you here? In order to ...
    4. Why are you here? In order to ... As a Scotland on Rails attendee
    5. Why are you here? In order to ... As a Scotland on Rails attendee I want ...
    6. What is your Acceptance Criteria?
    7. Scenario: Happy SoR attendees Given people turned up When Joseph talks Then everyone should acquire some new knowledge And no-one should fall asleep And no rotten food should be thrown
    8. Pass Fail
    9. Outside-in User Browser Views Controllers Models
    10. Cucumber “The feature you wished you had” Views Controllers Rspec Models “The components and the interactions you wish you had”
    11. Cucumber “The feature you wished you had” Views Controllers Rspec Models “The components and the interactions you wish you had”
    12. Cucumber “The feature you wished you had” Views Controllers Rspec Models “The components and the interactions you wish you had”
    13. Cucumber / Scenario
    14. Cucumber / Scenario
    15. Cucumber / Scenario Rspec / code examples
    16. Cucumber / Scenario Rspec / code examples
    17. Cucumber / Scenario Rspec / code examples
    18. Cucumber / Scenario Rspec / code examples
    19. Cucumber / Scenario Rspec / code examples
    20. :rspec => route finder :cucumber => destination London Edinburgh
    21. Behaviour Driven Development with elegance and joy
    22. Behaviour Driven Development with elegance and joy Just Cuke it!
    23. Plaintext Ruby Features step definitions
    24. Cucumber Feature Not executed Feature: Be awesome Narrative Scenario: title Example of Given <some context> behaviour And <yet more context> When <some action> And <more actions> Then <some outcome> And <more outcomes>
    25. regexp match Step definition Given /^we like (.*)$/i do |fruit| fruit.should == 'cukes' Ruby tests #assert_equal(fruit, 'cukes') end Plaintext Given we like cukes Feature Cucumber
    26. Plug and Pray Rspec Plaintext Ruby tests TestUnit Cucumber Ruby-Gnome2 Cucumber Sinatra Rails Merb iPhone
    27. Cucumber English
    28. огурец Russian Chinese concombre French Korean gurka Swedish Japanese German castravete Romanian Gurke ogórek Cucumber English Polish pepino Spanish Italian cetriolo Danish agurk ‫ﺍﳋﻴﺎﺭ‬ Arabic Indonisean ketimun
    29. огурец Russian Chinese concombre French Korean gurka Swedish Japanese German castravete Romanian Gurke ogórek Cucumber English Polish pepino Spanish Treetop Rocks Italian cetriolo ANTLR Danish agurk could rock ‫ﺍﳋﻴﺎﺭ‬ Arabic Indonisean harder ketimun
    30. Webrat Love visit home_path click_link \"Web\" fill_in \"Email\", :with => \"Rat” click_button \"Love\" Bansky
    31. Return On Investment Cucumber Feature
    32. Return On Investment Cucumber Feature • Token Conversation
    33. Return On Investment Cucumber Feature • Token Conversation • Acceptance Criteria
    34. Return On Investment Cucumber Feature • Token Conversation • Acceptance Criteria • Design
    35. Return On Investment Cucumber Feature • Token Conversation • Acceptance Criteria • Design • Documentation
    36. Return On Investment Cucumber Feature • Token Conversation • Acceptance Criteria • Design • Documentation • Functional test
    37. Return On Investment Cucumber Feature • Token Conversation • Acceptance Criteria • Design • Documentation • Functional test • Integration test
    38. Token for Conversation
    39. Feature Request I want members to be able to rent a movie with a priority indicating how much they want to see the film
    40. Show me the _ _ _ _ _
    41. Show me the VA L U _ ____E
    42. Root Cause Analysis
    43. Root Cause Analysis Why? So we can maximise allocation of films
    44. Root Cause Analysis Why? Keep customers happy Why? So we can maximise allocation of films
    45. Root Cause Analysis Why? So they continue with their subscriptions Why? Keep customers happy Why? So we can maximise allocation of films
    46. Root Cause Analysis Why? So they continue with their subscriptions Why? Keep customers happy Why? So we can maximise allocation of films
    47. Lets write our Cucumber feature
    48. Feature (terrible) Value Feature: select a movie to rent with priority In order to maximise allocation of films The website user Needs to be able to add movies to their rental list with a priority Role Feature
    49. Feature (terrible) Value Feature: select a movie to rent with priority In order to maximise allocation of films Narrative The website user Needs to be able to add movies to their rental list with a priority Role Feature
    50. Feature (terrible) Value Feature: select a movie to rent with priority In order to maximise allocation of films The website user Needs to be able to add movies to their rental list with a priority Role Feature
    51. Feature (terrible) Feature: select a movie to rent with priority In order to maximise allocation of films The website user Needs to be able to add movies to their rental list with a priority
    52. Feature (terrible) Feature: select a movie to rent with priority In order to maximise allocation of films The website user Needs to be able to add movies to their rental list with a priority Noise
    53. Feature (terrible) Feature: select a movie to rent with priority In order to maximise allocation of films The website user Needs to be able to add movies to their rental list with a priority Too generic role
    54. Feature (terrible) Feature: select a movie to rent with priority In order to maximise allocation of films The website user Film member Needs to be able to add movies to their rental list with a priority Too generic role
    55. Feature (terrible) Role can change feature Feature: select a movie to rent with priority In order to maximise allocation of films The website user Film member Needs to be able to add movies to their rental list with a priority
    56. Feature (terrible) Role can change feature Film Member selects a movie to rent with priority Feature: select a movie to rent with priority In order to maximise allocation of films The website user Film member Needs to be able to add movies to their rental list with a priority
    57. Nice Feature (terrible) Film Member selects a movie to rent with priority Feature: select a movie to rent with priority In order to maximise allocation of films The website user Film member Needs to be able to add movies to their rental list with a priority
    58. Acceptance Definition of Done.
    59. Scenarios Feature: Film Member selects a movie to rent with priority In order to maximise allocation of films The Film member Needs to add movies to their rental list with a priority Scenario: High priority
    60. Scenarios Feature: Film Member selects a movie to rent with priority In order to maximise allocation of films The Film member Needs to add movies to their rental list with a priority Scenario: High priority Then I should see \"My rental list\" And I should see \"Casshern\" in my rental list And \"Casshern\" should be marked as \"High priority\"
    61. Scenarios Feature: Film Member selects a movie to rent with priority In order to maximise allocation of films The Film member Needs to add movies to their rental list with a priority Scenario: High priority When I choose \"High priority\" And I press \"Rent\" Then I should see \"My rental list\" And I should see \"Casshern\" in my rental list And \"Casshern\" should be marked as \"High priority\"
    62. Scenarios Feature: Film Member selects a movie to rent with priority In order to maximise allocation of films The Film member Needs to add movies to their rental list with a priority Scenario: High priority Given I'm logged in And I am viewing the movie \"Casshern\" When I choose \"High priority\" And I press \"Rent\" Then I should see \"My rental list\" And I should see \"Casshern\" in my rental list And \"Casshern\" should be marked as \"High priority\"
    63. Let there be Cuking
    64. Demo High Resolution: http://www.screencast.com/t/aG1sE4N3Zq Low Resolution: http://www.vimeo.com/3910617
    65. Here’s one I Cuked earlier
    66. Demo High Resolution: http://www.screencast.com/t/tlBYxkKci Low Resolution http://www.vimeo.com/3911104
    67. Installing Cucumber $ sudo gem install cucumber $ script/plugin install git://github.com/aslakhellesoy/ cucumber.git $ gem sources -a http://gems.github.com $ sudo gem install aslakhellesoy-cucumber
    68. Fixtures Scenario: search results found Given /^the Movies$/i do |movie_hash| Given the Movies #{:title => \"The colour white\"}, | title | #{:title => \"The colour red\"}, | The colour white | #{:title => \"Casshern\"} | The colour red | movies.hashes.each do |values| | Casshern | Movie.create!(values) When I search for \"colour\" end Then I will see 2 results end Scenario: search results found Given 2 films with \"colour\" in the title When I search for \"colour\" Then I will see 2 results
    69. Stick it to the World module NavigationHelpers def path_to(page_name) case page_name when /the homepage/ root_path else raise \"Can't find mapping from \\\"#{page_name}\\\" to a path.\" end end end World do |world| world.extend NavigationHelpers world end
    70. Hooks Hooks are GLOBAL! Before do # do something before each scenario. end After do #do something after each scenario end
    71. How many scenarios is enough? • Given/When/Then “Finite state machine” Uncle Bob • What’s the Return on Investment?
    72. Cowcumbers (Bad smells) “fit only for consumption by cows”
    73. Cowcumbers Given /^dirty state$/ do @movie = Movie.create! Relying on state (too much) end Given /^coupled by state$/ do @movie.title = \"yucky\" end Given /^does a user care$/ do response.current_url == ‘silly’ end Tests without user value Given /^checking the db$/ do Movie.find(1).should_not == nil end
    74. Building your DSL
    75. Concrete vs Abstract Scenarios Given I'm logged in Given I go to the login page And I fill in \"username\" with \"joseph\" And I fill in \"password\" with \"cuker\" And I click \"login\" Domain understanding Concrete Abstract
    76. Calling steps from steps Given /I’m logged in/ do User.create!(:user => 'josephwilk', :password => \"pass\") Given 'I fill in \"password\" with \"josephwilk\"' Given 'I fill in \"password\" with \"pass\"' Given 'I click \"login\"' end
    77. Feature Request Can you add some of that funky AJAX stuff for the rent button
    78. JavaScript kills Webrat
    79. Watir, Selenium & Celerity Browser based Headless Browser • • Watir Celerity • • Selenium Culerity - http:// github.com/langalex/ culerity/tree/master
    80. Webrat / Selenium # Sets up the Rails environment for Cucumber ENV[\"RAILS_ENV\"] ||= \"selenium\" require File.expand_path(File.dirname(__FILE__) + '/../../config/environment') require 'cucumber/rails/world' require 'cucumber/formatters/unicode' Turn off #Cucumber::Rails.use_transactional_fixtures require 'webrat' Webrat.configure do |config| Switch to Selenium config.mode = :selenium end require 'cucumber/rails/rspec' require 'webrat/core/matchers' Before do Movie.delete_all Manually cleanup RentalRequest.delete_all end
    81. Organising @in-progress Feature: Verify billing Tag @js Scenario: Missing product description Scenario: Several products cucumber --profile rails --tags ~@js cucumber --profile browser --tags @js
    82. Demo High Resolution: http://www.screencast.com/t/1jRSI6TvXWu Low Resolution: http://www.vimeo.com/3911241
    83. Further reading • http://cukes.info • http://wiki.github.com/ aslakhellesoy/cucumber • http://rspec.info/ • http://blog.josephwilk.net
    84. Thanks joe@josephwilk.net http://github.com/josephwilk

    + Joseph WilkJoseph Wilk, 7 months ago

    custom

    3170 views, 25 favs, 5 embeds more stats

    Talk given by Joseph Wilk at Scotland on Rails 2009 more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 3170
      • 2380 on SlideShare
      • 790 from embeds
    • Comments 0
    • Favorites 25
    • Downloads 0
    Most viewed embeds
    • 779 views on http://blog.josephwilk.net
    • 4 views on http://please.dontrush.org
    • 4 views on http://www.ozmox.com
    • 2 views on http://www.joesniff.co.uk
    • 1 views on https://go2http.appspot.com

    more

    All embeds
    • 779 views on http://blog.josephwilk.net
    • 4 views on http://please.dontrush.org
    • 4 views on http://www.ozmox.com
    • 2 views on http://www.joesniff.co.uk
    • 1 views on https://go2http.appspot.com

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories