SlideShare una empresa de Scribd logo
1 de 12
Descargar para leer sin conexión
Athens Ruby                    16/3/2012
meetup #8




    Testing and BDD with
    RSpec and Cucumber

         Theodoros Orfanidis
              (aka @teoulas)
About me


     ●
         Web developer
     ●
         Ruby lover
     ●
         Cat lover �
     ●
         Tech lead at incrediblue.com



Athens ruby meetup #8                   16/3/2012
BDD concepts


     ●
         Describe what your system does
         (Given, When, Then)
     ●
         Write features/specs first, code later
     ●
         Red-Green-Refactor cycle (just like TDD)



Athens ruby meetup #8                               16/3/2012
BDD cycle

                                     1



                                     2




                            4               3


                                  RSpec

                        6                       5

                                 Cucumber


Athens ruby meetup #8                               16/3/2012
Cucumber


     ●
         Higher level
     ●
         Closer to natural language
         (any language, even LOLspeak!)
     ●
         Tests application behavior



Athens ruby meetup #8                     16/3/2012
Cucumber – Features

Feature: LOLcat competition submission
  In order to win the competition
  As a cat owner
  I want to submit a cat picture
  Scenario: Cat owner submits picture
    Given I have a cat
    And I have a funny picture of her
    When I upload the picture
    Then I should see “KTHX! Bai!”
  Scenario: Cat owner submits a second picture
    Given I have already uploaded a picture
    When I upload another picture
    Then I should see “Oh noes, naughty boi!”
    And I should see my previous submission


 Athens ruby meetup #8                           16/3/2012
Cucumber – Step definitions

Given /^I have uploaded a picture$/ do
  @first = Submission.new(title: “My 1337 cat!”,
    image: File.open Rails.root + “tmp/sample1.jpg”)
end
When /^I upload another picture$/ do
  @another = Submission.new(title: “My cat again”,
    image: File.open Rails.root + “tmp/sample2.jpg”)
end

Then /^I should see “([^”]*)”$/ do |msg|
  page.should have_content(msg)
end




 Athens ruby meetup #8                                 16/3/2012
RSpec



     ●
         Lower level
     ●
         Closer to code
     ●
         Tests object behaviour




Athens ruby meetup #8             16/3/2012
RSpec

describe “submission” do
  it “should allow jpg images” do
    sub = Submission.new(title: “Cat”,
      image: File.open Rails.root + “tmp/sample.jpg”)
    sub.should be_valid
  end
  it “should not allow gif images” do
    sub = Submission.new(title: “Cat”,
      image: File.open Rails.root + “tmp/animated.gif”)
    sub.should_not be_valid
  end
end




 Athens ruby meetup #8                                    16/3/2012
Demo app




Athens ruby meetup #8              16/3/2012
Related libraries and tools


     ●
         FactoryGirl
     ●
         Capybara
     ●
         Selenium
     ●
         Guard
     ●
         Spork


Athens ruby meetup #8                  16/3/2012
Thanks!




Athens ruby meetup #8             16/3/2012

Más contenido relacionado

Similar a Athens Ruby meetup #8

Merb The Super Bike Of Frameworks
Merb The Super Bike Of FrameworksMerb The Super Bike Of Frameworks
Merb The Super Bike Of FrameworksRowan Hick
 
Fukuoka Ruby Award 2023 - Opal
Fukuoka Ruby Award 2023 - OpalFukuoka Ruby Award 2023 - Opal
Fukuoka Ruby Award 2023 - OpalAndy Maleh
 
Exploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQLExploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQLBarry Jones
 
Rapid RIA development with Netzke
Rapid RIA development with NetzkeRapid RIA development with Netzke
Rapid RIA development with Netzkenetzke
 
Introduction to Ruby on Rails
Introduction to Ruby on RailsIntroduction to Ruby on Rails
Introduction to Ruby on RailsManoj Kumar
 
Enjoy Ruby Programming in IDE and TypeProf
Enjoy Ruby Programming in IDE and TypeProfEnjoy Ruby Programming in IDE and TypeProf
Enjoy Ruby Programming in IDE and TypeProfmametter
 
How to discover the Ruby's defects with web application
How to discover the Ruby's defects with web applicationHow to discover the Ruby's defects with web application
How to discover the Ruby's defects with web applicationHiroshi SHIBATA
 
The Future of Dependency Management for Ruby
The Future of Dependency Management for RubyThe Future of Dependency Management for Ruby
The Future of Dependency Management for RubyHiroshi SHIBATA
 
Rails Development That Doesn't Hurt
Rails Development That Doesn't HurtRails Development That Doesn't Hurt
Rails Development That Doesn't HurtAkira Matsuda
 
2016-05-12 DCRUG React.rb
2016-05-12 DCRUG React.rb2016-05-12 DCRUG React.rb
2016-05-12 DCRUG React.rbawwaiid
 
Rspec and Capybara Intro Tutorial at RailsConf 2013
Rspec and Capybara Intro Tutorial at RailsConf 2013Rspec and Capybara Intro Tutorial at RailsConf 2013
Rspec and Capybara Intro Tutorial at RailsConf 2013Brian Sam-Bodden
 
Introduction to RDoc
Introduction to RDocIntroduction to RDoc
Introduction to RDocTim Lucas
 
Introduction to RDoc
Introduction to RDocIntroduction to RDoc
Introduction to RDocTim Lucas
 
Puppet Camp Paris 2014: Test Driven Development
Puppet Camp Paris 2014: Test Driven DevelopmentPuppet Camp Paris 2014: Test Driven Development
Puppet Camp Paris 2014: Test Driven DevelopmentPuppet
 
20140408 tdd puppetcamp-paris
20140408 tdd puppetcamp-paris20140408 tdd puppetcamp-paris
20140408 tdd puppetcamp-parisJohan De Wit
 
Ruby on Rails: a brief introduction
Ruby on Rails: a brief introductionRuby on Rails: a brief introduction
Ruby on Rails: a brief introductionLuigi De Russis
 

Similar a Athens Ruby meetup #8 (20)

Merb The Super Bike Of Frameworks
Merb The Super Bike Of FrameworksMerb The Super Bike Of Frameworks
Merb The Super Bike Of Frameworks
 
Fukuoka Ruby Award 2023 - Opal
Fukuoka Ruby Award 2023 - OpalFukuoka Ruby Award 2023 - Opal
Fukuoka Ruby Award 2023 - Opal
 
Exploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQLExploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQL
 
Rapid RIA development with Netzke
Rapid RIA development with NetzkeRapid RIA development with Netzke
Rapid RIA development with Netzke
 
Introduction to Ruby on Rails
Introduction to Ruby on RailsIntroduction to Ruby on Rails
Introduction to Ruby on Rails
 
Enjoy Ruby Programming in IDE and TypeProf
Enjoy Ruby Programming in IDE and TypeProfEnjoy Ruby Programming in IDE and TypeProf
Enjoy Ruby Programming in IDE and TypeProf
 
rubyonrails
rubyonrailsrubyonrails
rubyonrails
 
rubyonrails
rubyonrailsrubyonrails
rubyonrails
 
Ruby on Rails Presentation
Ruby on Rails PresentationRuby on Rails Presentation
Ruby on Rails Presentation
 
How to discover the Ruby's defects with web application
How to discover the Ruby's defects with web applicationHow to discover the Ruby's defects with web application
How to discover the Ruby's defects with web application
 
The Future of Dependency Management for Ruby
The Future of Dependency Management for RubyThe Future of Dependency Management for Ruby
The Future of Dependency Management for Ruby
 
Go at Skroutz
Go at SkroutzGo at Skroutz
Go at Skroutz
 
Rails Development That Doesn't Hurt
Rails Development That Doesn't HurtRails Development That Doesn't Hurt
Rails Development That Doesn't Hurt
 
2016-05-12 DCRUG React.rb
2016-05-12 DCRUG React.rb2016-05-12 DCRUG React.rb
2016-05-12 DCRUG React.rb
 
Rspec and Capybara Intro Tutorial at RailsConf 2013
Rspec and Capybara Intro Tutorial at RailsConf 2013Rspec and Capybara Intro Tutorial at RailsConf 2013
Rspec and Capybara Intro Tutorial at RailsConf 2013
 
Introduction to RDoc
Introduction to RDocIntroduction to RDoc
Introduction to RDoc
 
Introduction to RDoc
Introduction to RDocIntroduction to RDoc
Introduction to RDoc
 
Puppet Camp Paris 2014: Test Driven Development
Puppet Camp Paris 2014: Test Driven DevelopmentPuppet Camp Paris 2014: Test Driven Development
Puppet Camp Paris 2014: Test Driven Development
 
20140408 tdd puppetcamp-paris
20140408 tdd puppetcamp-paris20140408 tdd puppetcamp-paris
20140408 tdd puppetcamp-paris
 
Ruby on Rails: a brief introduction
Ruby on Rails: a brief introductionRuby on Rails: a brief introduction
Ruby on Rails: a brief introduction
 

Último

Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
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, ...apidays
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
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 FMESafe Software
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
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 DiscoveryTrustArc
 

Último (20)

Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
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, ...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
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...
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
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
 

Athens Ruby meetup #8

  • 1. Athens Ruby 16/3/2012 meetup #8 Testing and BDD with RSpec and Cucumber Theodoros Orfanidis (aka @teoulas)
  • 2. About me ● Web developer ● Ruby lover ● Cat lover � ● Tech lead at incrediblue.com Athens ruby meetup #8 16/3/2012
  • 3. BDD concepts ● Describe what your system does (Given, When, Then) ● Write features/specs first, code later ● Red-Green-Refactor cycle (just like TDD) Athens ruby meetup #8 16/3/2012
  • 4. BDD cycle 1 2 4 3 RSpec 6 5 Cucumber Athens ruby meetup #8 16/3/2012
  • 5. Cucumber ● Higher level ● Closer to natural language (any language, even LOLspeak!) ● Tests application behavior Athens ruby meetup #8 16/3/2012
  • 6. Cucumber – Features Feature: LOLcat competition submission In order to win the competition As a cat owner I want to submit a cat picture Scenario: Cat owner submits picture Given I have a cat And I have a funny picture of her When I upload the picture Then I should see “KTHX! Bai!” Scenario: Cat owner submits a second picture Given I have already uploaded a picture When I upload another picture Then I should see “Oh noes, naughty boi!” And I should see my previous submission Athens ruby meetup #8 16/3/2012
  • 7. Cucumber – Step definitions Given /^I have uploaded a picture$/ do @first = Submission.new(title: “My 1337 cat!”, image: File.open Rails.root + “tmp/sample1.jpg”) end When /^I upload another picture$/ do @another = Submission.new(title: “My cat again”, image: File.open Rails.root + “tmp/sample2.jpg”) end Then /^I should see “([^”]*)”$/ do |msg| page.should have_content(msg) end Athens ruby meetup #8 16/3/2012
  • 8. RSpec ● Lower level ● Closer to code ● Tests object behaviour Athens ruby meetup #8 16/3/2012
  • 9. RSpec describe “submission” do it “should allow jpg images” do sub = Submission.new(title: “Cat”, image: File.open Rails.root + “tmp/sample.jpg”) sub.should be_valid end it “should not allow gif images” do sub = Submission.new(title: “Cat”, image: File.open Rails.root + “tmp/animated.gif”) sub.should_not be_valid end end Athens ruby meetup #8 16/3/2012
  • 10. Demo app Athens ruby meetup #8 16/3/2012
  • 11. Related libraries and tools ● FactoryGirl ● Capybara ● Selenium ● Guard ● Spork Athens ruby meetup #8 16/3/2012