SlideShare une entreprise Scribd logo
1  sur  60
Télécharger pour lire hors ligne
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?
Cucumbers & Factory Girls
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
Cucumbers & Factory Girls
/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
Cucumbers & Factory Girls
Cucumbers & Factory Girls
Cucumbers & Factory Girls
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

Contenu connexe

Plus de Tim Lucas

Introducing... Bananajour!
Introducing... Bananajour!Introducing... Bananajour!
Introducing... Bananajour!Tim Lucas
 
RORO May Lightning Preso Madness
RORO May Lightning Preso MadnessRORO May Lightning Preso Madness
RORO May Lightning Preso MadnessTim Lucas
 
Introducing me, and Ruby on Rails
Introducing me, and Ruby on RailsIntroducing me, and Ruby on Rails
Introducing me, and Ruby on RailsTim Lucas
 
Developing for iPhone
Developing for iPhoneDeveloping for iPhone
Developing for iPhoneTim Lucas
 
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 RailsTim 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.auTim Lucas
 
Matthew Landauer - Open Australia
Matthew Landauer - Open AustraliaMatthew Landauer - Open Australia
Matthew Landauer - Open AustraliaTim Lucas
 
Matt Allen - Unfuddle your bugs
Matt Allen - Unfuddle your bugsMatt Allen - Unfuddle your bugs
Matt Allen - Unfuddle your bugsTim Lucas
 
Introduction to RDoc
Introduction to RDocIntroduction to RDoc
Introduction to RDocTim Lucas
 
Introduction to RDoc
Introduction to RDocIntroduction to RDoc
Introduction to RDocTim Lucas
 

Plus de 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
 

Dernier

Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration WorkflowsIgniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration WorkflowsSafe Software
 
Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™Adtran
 
UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8DianaGray10
 
UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6DianaGray10
 
Designing A Time bound resource download URL
Designing A Time bound resource download URLDesigning A Time bound resource download URL
Designing A Time bound resource download URLRuncy Oommen
 
OpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureOpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureEric D. Schabell
 
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfIaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfDaniel Santiago Silva Capera
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024D Cloud Solutions
 
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfJamie (Taka) Wang
 
Empowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintEmpowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintMahmoud Rabie
 
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesAI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesMd Hossain Ali
 
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDEADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDELiveplex
 
Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1DianaGray10
 
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...Aggregage
 
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...DianaGray10
 
UiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPathCommunity
 
Introduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxIntroduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxMatsuo Lab
 
Cybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxCybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxGDSC PJATK
 
Bird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemBird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemAsko Soukka
 

Dernier (20)

Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration WorkflowsIgniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
 
Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™
 
UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8
 
UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6
 
Designing A Time bound resource download URL
Designing A Time bound resource download URLDesigning A Time bound resource download URL
Designing A Time bound resource download URL
 
OpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureOpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability Adventure
 
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfIaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024
 
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
 
Empowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintEmpowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership Blueprint
 
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesAI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
 
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDEADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
 
Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1
 
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
 
201610817 - edge part1
201610817 - edge part1201610817 - edge part1
201610817 - edge part1
 
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
 
UiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation Developers
 
Introduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxIntroduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptx
 
Cybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxCybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptx
 
Bird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemBird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystem
 

Cucumbers & Factory Girls