Slide 1

Slide 1 text

Cucumber It’s about talking not testing Chris Parsons (@chrismdp) Friday, 29 June 12

Slide 2

Slide 2 text

GardenApp 1.0 Friday, 29 June 12

Slide 3

Slide 3 text

Kick off meeting Friday, 29 June 12

Slide 4

Slide 4 text

Friday, 29 June 12

Slide 5

Slide 5 text

Friday, 29 June 12

Slide 6

Slide 6 text

Feature: User orders plant As a user of the website, I want to place an order on the website, so that I can order a plant through the website Scenario: User orders plant Given there is a plant with name: “Plant 1”, price: “£1”, size: “large”, foliage: “foliage 1” When I visit the homepage And I click on “Plant 1” And I click “Add” Friday, 29 June 12

Slide 7

Slide 7 text

And I fill in “City” with “City 1” And I fill in “Postcode” with “SW1A 1AA” And I click “Continue” And I click “Continue” And I fill in “Card number” with “1234 1234 1234 1234” And I fill in “Expiry date” with “00/00” And I fill in “Name on Card” with “Name on Card 1” And I fill in “CV2” with “123” And I click “Place Order” Then I should receive an email Friday, 29 June 12

Slide 8

Slide 8 text

What is Cucumber? Friday, 29 June 12

Slide 9

Slide 9 text

$ mkdir features $ vim features/ first.feature $ cucumber Friday, 29 June 12

Slide 10

Slide 10 text

Myth #1: Cucumber was made for us. Friday, 29 June 12

Slide 11

Slide 11 text

Listening Friday, 29 June 12

Slide 12

Slide 12 text

“So, I’m thinking of a gardening website, where you can buy stuff...” Friday, 29 June 12

Slide 13

Slide 13 text

“...but with a way for those who love gardening to make it a whole interactive experience, right?” Friday, 29 June 12

Slide 14

Slide 14 text

“So gardeners can create like an ‘area’ to put pictures of their plants...” Friday, 29 June 12

Slide 15

Slide 15 text

“...and other gardeners can say what they think, and suggest garden layout improvements...” Friday, 29 June 12

Slide 16

Slide 16 text

“Herp derpety derp derp herp herpity derp website derp herp derp buy stuff” Friday, 29 June 12

Slide 17

Slide 17 text

“...derpety herpity derpety herpity users derp herp social derp?” Friday, 29 June 12

Slide 18

Slide 18 text

“Users herp derp account derpety users#show derp photos (hmm, EC2 storage; which gem? Add day to estimate)” Friday, 29 June 12

Slide 19

Slide 19 text

“...herp herpity herp derp ratings derpity comments” Friday, 29 June 12

Slide 20

Slide 20 text

Myth #2: Cucumber features capture everything. Friday, 29 June 12

Slide 21

Slide 21 text

What is a feature? Friday, 29 June 12

Slide 22

Slide 22 text

The feature is not the feature. Friday, 29 June 12

Slide 23

Slide 23 text

Friday, 29 June 12

Slide 24

Slide 24 text

Reminder of communication Friday, 29 June 12

Slide 25

Slide 25 text

Record of communication Friday, 29 June 12

Slide 26

Slide 26 text

Reek Detector for communication Friday, 29 June 12

Slide 27

Slide 27 text

Myth #3: Cucumber is a testing tool. Friday, 29 June 12

Slide 28

Slide 28 text

“Why?” not “How?” Friday, 29 June 12

Slide 29

Slide 29 text

Feature: User orders plant As a user of the website, I want to place an order on the website, so that I can order a plant through the website Scenario: User orders plant Given there is a plant with name: “Plant 1”, price: “£1”, size: “large”, foliage: “foliage 1” When I visit the homepage And I click on “Plant 1” And I click “Add” Friday, 29 June 12

Slide 30

Slide 30 text

And I fill in “City” with “City 1” And I fill in “Postcode” with “SW1A 1AA” And I click “Continue” And I click “Continue” And I fill in “Card number” with “1234 1234 1234 1234” And I fill in “Expiry date” with “00/00” And I fill in “Name on Card” with “Name on Card 1” And I fill in “CV2” with “123” And I click “Place Order” Then I should receive an email Friday, 29 June 12

Slide 31

Slide 31 text

Given /there (?:is|are) (a|\d+) (\w+) with ((\w+): (\w+) )+$/ do |count, name, fields| count = count == “a” ? 1 : count.to_i params = {} fields.each do |field| params[field[0]] = field[1] end count.times { name.classify.create! (params) } end Friday, 29 June 12

Slide 32

Slide 32 text

....FF...FFFUUU Friday, 29 June 12

Slide 33

Slide 33 text

GardenApp 2.0 Friday, 29 June 12

Slide 34

Slide 34 text

Ubiquitous Language Friday, 29 June 12

Slide 35

Slide 35 text

“So, I’m thinking of a gardening website, where you can buy stuff...” Friday, 29 June 12

Slide 36

Slide 36 text

“...but with a way for those who love gardening to make it a whole interactive experience, right?” Friday, 29 June 12

Slide 37

Slide 37 text

“So gardeners can create like an ‘area’ to put pictures of their plants...” Friday, 29 June 12

Slide 38

Slide 38 text

“...and other gardeners can say what they think, and suggest garden layout improvements...” Friday, 29 June 12

Slide 39

Slide 39 text

Feature: User orders plant As Gareth the aspiring gardener, I want to buy plants I’ve seen shared on other gardeners uploaded layouts, so that I can improve my own garden with ideas from others Friday, 29 June 12

Slide 40

Slide 40 text

Scenario: Gareth buys plants When “Gareth” buys a recommended plant Then the order should be placed Friday, 29 June 12

Slide 41

Slide 41 text

Scenario: Gareth supplies incorrect information When “Gareth” enters incorrect information during a purchase Then he is shown an appropriate error And the order does not get placed Friday, 29 June 12

Slide 42

Slide 42 text

When /^“(.+)” buys a recommended plant$/ do |name| place_order(user_for(name)) end Then /^the order should be placed$/ do |name| check_order_placed(user_for(name)) end Friday, 29 June 12

Slide 43

Slide 43 text

When /^“(.+)” enters incorrect information during a purchase$/ do |name| place_order(user_for(name)) do fill_in :credit_card, :with => “bad” end end Friday, 29 June 12

Slide 44

Slide 44 text

def user_for(name) User.find_by_name(name) || User.create(:name => name) end def place_order(user) visit order_path fill_in :name, :with => user.name yield if block_given? click_button “Submit” end Friday, 29 June 12

Slide 45

Slide 45 text

You don’t have to use it! Friday, 29 June 12

Slide 46

Slide 46 text

Are we really listening? Friday, 29 June 12

Slide 47

Slide 47 text

Are we just checking it works? Friday, 29 June 12

Slide 48

Slide 48 text

Friday, 29 June 12

Slide 49

Slide 49 text

Coupon Code: SCOTRUBY for 20% off Friday, 29 June 12

Slide 50

Slide 50 text

Chris Parsons @chrismdp http://bddkickstart.com Friday, 29 June 12