SlideShare ist ein Scribd-Unternehmen logo
1 von 60
Downloaden Sie, um offline zu lesen
CUCUMBERS! AND FACTORY GIRLS
CUCUMBER
STORIES
210 SCENARIOS
BIG BULLSHIT NUMBERS
In order to show the world how cool they are
A user
Should be able to edit and update their personal details
RSPEC STORIES
As a user
I want to edit and update my personal details
So that I can show the world how cool I am
OLD SCHOOL
GOOD OLD SCHOOL




                                     PHOTO BY:
                  flickr.com/people/rumberodesign
BAD OLD SCHOOL
BENEFITS OF CUCUMBER?
HIGH WATER CONTENT
SKIN IS RICH IN FIBER
REGULATE BLOOD PRESSURE
RUBY + CUCUMBERS?
JAPAN + CUCUMBERS?
http://www.youtube.com/watch?v=fBsyBjQuX6E




http://www.youtube.com/watch?v=U3OxKdDxkpg
http://github.com/aslakhellesoy/cucumber/
DEMO: WEBJAM
http://github.com/webjam/webjam - rake features
/features
/features/*.feature
Story: Viewing the home page

  As a visitor
  I want to visit the home page
  So that I can see all the cool stuff

  Scenario: not logged in
    Given I am not logged in
    When I view the home page
    Then I see the page




/features/home.feature
/features/steps
/features/steps/*_steps.rb
When quot;I view the home pagequot; do
   get home_path
 end




/features/home_steps.rb
Then quot;I see the pagequot; do
   response.code.should == quot;200quot;
 end




/features/response_steps.rb
FEATURES
RUBY
RAILS INTEGRATION
TREETOP
STORY RUNNER COMPATIBLE
FIT TABLES
Feature: Addition
  In order to avoid silly mistakes
  As a math idiot
  I want to be told the sum of two numbers

  Scenario: Add two numbers
    Given I have entered 50 into the calculator
    And I have entered 70 into the calculator
    When I press add
    Then the result should be 120 on the screen
    And the result class should be Fixnum

   |   input_1   |   input_2   |   button   |   output   |   class    |
   |   20        |   30        |   add      |   50       |   Fixnum   |
   |   2         |   5         |   add      |   7        |   Fixnum   |
   |   0         |   40        |   add      |   40       |   Fixnum   |
Before do
  @calc = Calculator.new
end

After do
end

Given quot;I have entered $n into the calculatorquot; do |n|
  @calc.push n.to_i
end

When /I press (w+)/ do |op|
  @result = @calc.send op
end

Then /the result should be (.*) on the screen/ do |result|
  @result.should == result.to_f
end

Then /the result class should be (w*)/ do |class_name|
  @result.class.name.should == class_name
end
Before do
  @calc = Calculator.new
end

After do
end

Given quot;I have entered $n into the calculatorquot; do |n|
  @calc.push n.to_i
end

When /I press (w+)/ do |op|
  @result = @calc.send op
end

Then /the result should be (.*) on the screen/ do |result|
  @result.should == result.to_f
end

Then /the result class should be (w*)/ do |class_name|
  @result.class.name.should == class_name
end
Before do
  @calc = Calculator.new
end

After do
end

Given quot;I have entered $n into the calculatorquot; do |n|
  @calc.push n.to_i
end

When /I press (w+)/ do |op|
  @result = @calc.send op
end

Then /the result should be (.*) on the screen/ do |result|
  @result.should == result.to_f
end

Then /the result class should be (w*)/ do |class_name|
  @result.class.name.should == class_name
end
Before do
  @calc = Calculator.new
end

After do
end

Given quot;I have entered $n into the calculatorquot; do |n|
  @calc.push n.to_i
end

When /I press (w+)/ do |op|
  @result = @calc.send op
end

Then /the result should be (.*) on the screen/ do |result|
  @result.should == result.to_f
end

Then /the result class should be (w*)/ do |class_name|
  @result.class.name.should == class_name
end
Feature: Addition
  In order to avoid silly mistakes
  As a math idiot
  I want to be told the sum of two numbers

  Scenario: Add two numbers
    Given I have entered 50 into the calculator
    And I have entered 70 into the calculator
    When I press add
    Then the result should be 120 on the screen
    And the result class should be Fixnum

   |   input_1   |   input_2   |   button   |   output   |   class    |
   |   20        |   30        |   add      |   50       |   Fixnum   |
   |   2         |   5         |   add      |   7        |   Fixnum   |
   |   0         |   40        |   add      |   40       |   Fixnum   |
Feature: Addition
  In order to avoid silly mistakes
  As a math idiot
  I want to be told the sum of two numbers

  Scenario: Add two numbers
    Given I have entered 50 into the calculator
    And I have entered 70 into the calculator
    When I press add
    Then the result should be 120 on the screen
    And the result class should be Fixnum

    |   input_1   |   input_2   |   button   |   output   |   class    |
    |   20        |   30        |   add      |   50       |   Fixnum   |
    |   2         |   5         |   add      |   7        |   Fixnum   |
    |   0         |   40        |   add      |   40       |   Fixnum   |
GETTING STARTED
  WITH RAILS
INSTALL PLUGIN
./script/generate cucumber
FACTORY GIRL
INSTANTIATING MODELS
FIXTURELESS
SPECS and/or STORIES
HORNSBY



    LACHIE (LACHIE COX)
MACHINIST



     NOTAHAT (PETE YANDELL)
AGAIN, WEBJAM
http://github.com/webjam/webjam/tree/master/spec/factories.rb
Factory.define :presentation, :class => Jam do |p|
  p.title 'Preso title'
  p.description 'Preso description'
  p.number {Factory.next(:jam_number)}
  p.users {|u| [u.association(:user)]}
  p.association :event
end
When quot;I view an event presentation pagequot; do
  @event = Factory.create(:past_event)
  @presentation = Factory.create(:presentation,
                                 :event => @event)
  get event_presentation_path(@event, @presentation)
end
ASSOCIATIONS
SEQUENCES
TIM LUCAS
TWITTER.COM/TOOLMANTIM
TOOLMANTIM.COM

Weitere ähnliche Inhalte

Mehr von Tim Lucas

Improving performance of iphone.news.com.au
Improving performance of iphone.news.com.auImproving performance of iphone.news.com.au
Improving performance of iphone.news.com.au
Tim Lucas
 
Matt Allen - Unfuddle your bugs
Matt Allen - Unfuddle your bugsMatt Allen - Unfuddle your bugs
Matt Allen - Unfuddle your bugs
Tim Lucas
 

Mehr von Tim Lucas (11)

Introducing... Bananajour!
Introducing... Bananajour!Introducing... Bananajour!
Introducing... Bananajour!
 
RORO May Lightning Preso Madness
RORO May Lightning Preso MadnessRORO May Lightning Preso Madness
RORO May Lightning Preso Madness
 
Sinatra
SinatraSinatra
Sinatra
 
Introducing me, and Ruby on Rails
Introducing me, and Ruby on RailsIntroducing me, and Ruby on Rails
Introducing me, and Ruby on Rails
 
Developing for iPhone
Developing for iPhoneDeveloping for iPhone
Developing for iPhone
 
Just Built It - Introduction to Ruby on Rails
Just Built It - Introduction to Ruby on RailsJust Built It - Introduction to Ruby on Rails
Just Built It - Introduction to Ruby on Rails
 
Improving performance of iphone.news.com.au
Improving performance of iphone.news.com.auImproving performance of iphone.news.com.au
Improving performance of iphone.news.com.au
 
Matthew Landauer - Open Australia
Matthew Landauer - Open AustraliaMatthew Landauer - Open Australia
Matthew Landauer - Open Australia
 
Matt Allen - Unfuddle your bugs
Matt Allen - Unfuddle your bugsMatt Allen - Unfuddle your bugs
Matt Allen - Unfuddle your bugs
 
Introduction to RDoc
Introduction to RDocIntroduction to RDoc
Introduction to RDoc
 
Introduction to RDoc
Introduction to RDocIntroduction to RDoc
Introduction to RDoc
 

Kürzlich hochgeladen

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Kürzlich hochgeladen (20)

Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
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
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
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?
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
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
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 

Cucumbers & Factory Girls