SlideShare a Scribd company logo
1 of 26
Download to read offline
Ruby - a tester’s best friend
Peter Lind @peter_lind
Ruby, wait what?

 Born in 1993
 Object-oriented
 Dynamic
 Open Source
 Elegant syntax
 Focus on programmer happiness
 Great for scripting
 And for apps
 Ruby On Rails?
Basics

 [array]
 {hash_key: hash_value}
 {hash_key => hash_value}
 do |var| <block body> end
 { |var| <block body> }
 class ClassName <class body> end
 def method_name <method body> end

 local_variable, @instance_variable, @@class_variable,
 Constant, $global
Basics

 ruby script.rb

 IRB

 gems
 – gem install <library>

 rake
 – Rakefile
How to install

 Use version 1.9.2

 OSX / Linux
 – Might already have it
 – If not, use RVM
    • http://beginrescueend.com/rvm/install/

 Windows
 – Use Railsinstaller
   • http://railsinstaller.org/
Culture

 Ruby is your friend, not your parent
Culture

 Ruby is your friend, not your parent

 Everything can be redefined
Culture

 Ruby is your friend, not your parent

 Everything can be redefined

 Readability
Culture

 Ruby is your friend, not your parent

 Everything can be redefined

 Readability
Culture

 Ruby is your friend, not your parent

 Everything can be redefined

 Readability

 TDD/BDD
Tools

 Sinatra
 – Sinatra is a DSL for quickly creating web applications in Ruby
   with minimal effort
 – http://www.sinatrarb.com/
Tools

 Sinatra
 – Sinatra is a DSL for quickly creating web applications in Ruby
   with minimal effort
 – http://www.sinatrarb.com/

 Cucumber
 – BDD that talks to domain experts first and code second
 – http://cukes.info/
Cucumber

Features
– Describes scenarios
– In the Gherkin language, almost English (or over 40 other)
– Given, When, Then
Cucumber

Features
– Describes scenarios
– In the Gherkin language, almost English (or over 40 other)
– Given, When, Then

Step definitions
– In Ruby
– Available for Java, .NET others
Tools

 Sinatra
 – Sinatra is a DSL for quickly creating web applications in Ruby
   with minimal effort
 – http://www.sinatrarb.com/

 Cucumber
 – BDD that talks to domain experts first and code second
 – http://cukes.info/

 Capybara
 – Acceptance test framework for web applications
 – https://github.com/jnicklas/capybara
Cucumber and Capybara example


 http://www.youtube.com/watch?v=S5XQTOVTPYY

 https://github.com/peterlind/cuke4all
Java Web App




Tests
pets.feature
                                              Pickle
Feature: Manage pets

  Scenario: List pets
    Given a pet exists with name: "Fido", sort: 0, weight: 23
    When I go to the list pets page
    Then I should see "Fido"

  Scenario: Enter a pet                     Capybara
    Given I am on the enter pet page
    And I fill in "Name" with "Rufus"
    And I fill in "Sort" with "Cat"
    And I fill in "Weight" with "8"
    And I press "Save"
    Then a pet should exist with name: "Rufus", weight: 8
THANKS!

peter.lind@valtech.se
@peter_lind

More Related Content

What's hot

Jruby synergy-of-ruby-and-java
Jruby synergy-of-ruby-and-javaJruby synergy-of-ruby-and-java
Jruby synergy-of-ruby-and-java
Keith Bennett
 

What's hot (19)

Nashorn
NashornNashorn
Nashorn
 
Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1
 
JRuby Basics
JRuby BasicsJRuby Basics
JRuby Basics
 
Nashorn: JavaScript that doesn’t suck (ILJUG)
Nashorn: JavaScript that doesn’t suck (ILJUG)Nashorn: JavaScript that doesn’t suck (ILJUG)
Nashorn: JavaScript that doesn’t suck (ILJUG)
 
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory CourseRuby on Rails 101 - Presentation Slides for a Five Day Introductory Course
Ruby on Rails 101 - Presentation Slides for a Five Day Introductory Course
 
Security Goodness with Ruby on Rails
Security Goodness with Ruby on RailsSecurity Goodness with Ruby on Rails
Security Goodness with Ruby on Rails
 
O que há de novo no Rails 3
O que há de novo no Rails 3O que há de novo no Rails 3
O que há de novo no Rails 3
 
Skinny Framework Progress Situation
Skinny Framework Progress SituationSkinny Framework Progress Situation
Skinny Framework Progress Situation
 
JRuby in Java Projects
JRuby in Java ProjectsJRuby in Java Projects
JRuby in Java Projects
 
Jruby synergy-of-ruby-and-java
Jruby synergy-of-ruby-and-javaJruby synergy-of-ruby-and-java
Jruby synergy-of-ruby-and-java
 
Ruby for C#-ers (ScanDevConf 2010)
Ruby for C#-ers (ScanDevConf 2010)Ruby for C#-ers (ScanDevConf 2010)
Ruby for C#-ers (ScanDevConf 2010)
 
Ruby on Rails Presentation
Ruby on Rails PresentationRuby on Rails Presentation
Ruby on Rails Presentation
 
Grand Central Dispatch
Grand Central DispatchGrand Central Dispatch
Grand Central Dispatch
 
Ror Seminar With agilebd.org on 23 Jan09
Ror Seminar With agilebd.org on 23 Jan09Ror Seminar With agilebd.org on 23 Jan09
Ror Seminar With agilebd.org on 23 Jan09
 
Using Java from Ruby with JRuby IRB
Using Java from Ruby with JRuby IRBUsing Java from Ruby with JRuby IRB
Using Java from Ruby with JRuby IRB
 
Debugging on rails
Debugging on railsDebugging on rails
Debugging on rails
 
Rjb
RjbRjb
Rjb
 
I18nize Scala programs à la gettext
I18nize Scala programs à la gettextI18nize Scala programs à la gettext
I18nize Scala programs à la gettext
 
Lagergren jvmls-2013-final
Lagergren jvmls-2013-finalLagergren jvmls-2013-final
Lagergren jvmls-2013-final
 

Similar to Ruby - a tester's best friend

Introducing ruby on rails
Introducing ruby on railsIntroducing ruby on rails
Introducing ruby on rails
Priceen
 
Vivendo No Mundo Rails
Vivendo No Mundo RailsVivendo No Mundo Rails
Vivendo No Mundo Rails
Alisson Sales
 
Ruby tutorial
Ruby tutorialRuby tutorial
Ruby tutorial
knoppix
 
Rubyonrails 120409061835-phpapp02
Rubyonrails 120409061835-phpapp02Rubyonrails 120409061835-phpapp02
Rubyonrails 120409061835-phpapp02
sagaroceanic11
 
Workin ontherailsroad
Workin ontherailsroadWorkin ontherailsroad
Workin ontherailsroad
Jim Jones
 

Similar to Ruby - a tester's best friend (20)

Ruby on Rails 3 Day BC
Ruby on Rails 3 Day BCRuby on Rails 3 Day BC
Ruby on Rails 3 Day BC
 
Ruby - The Hard Bits
Ruby - The Hard BitsRuby - The Hard Bits
Ruby - The Hard Bits
 
How DSL works on Ruby
How DSL works on RubyHow DSL works on Ruby
How DSL works on Ruby
 
DiUS Computing Lca Rails Final
DiUS  Computing Lca Rails FinalDiUS  Computing Lca Rails Final
DiUS Computing Lca Rails Final
 
How to distribute Ruby to the world
How to distribute Ruby to the worldHow to distribute Ruby to the world
How to distribute Ruby to the world
 
Introducing ruby on rails
Introducing ruby on railsIntroducing ruby on rails
Introducing ruby on rails
 
Vivendo No Mundo Rails
Vivendo No Mundo RailsVivendo No Mundo Rails
Vivendo No Mundo Rails
 
Behavioural Testing Ruby/Rails Apps @ Scale - Rspec & Cucumber
       Behavioural Testing Ruby/Rails Apps @ Scale - Rspec & Cucumber       Behavioural Testing Ruby/Rails Apps @ Scale - Rspec & Cucumber
Behavioural Testing Ruby/Rails Apps @ Scale - Rspec & Cucumber
 
Ruby tutorial
Ruby tutorialRuby tutorial
Ruby tutorial
 
rubyonrails
rubyonrailsrubyonrails
rubyonrails
 
rubyonrails
rubyonrailsrubyonrails
rubyonrails
 
Gemification for Ruby 2.5/3.0
Gemification for Ruby 2.5/3.0Gemification for Ruby 2.5/3.0
Gemification for Ruby 2.5/3.0
 
Capybara and cucumber with DSL using ruby
Capybara and cucumber with DSL using rubyCapybara and cucumber with DSL using ruby
Capybara and cucumber with DSL using ruby
 
Rubyonrails 120409061835-phpapp02
Rubyonrails 120409061835-phpapp02Rubyonrails 120409061835-phpapp02
Rubyonrails 120409061835-phpapp02
 
Puppet getting started by Dirk Götz
Puppet getting started by Dirk GötzPuppet getting started by Dirk Götz
Puppet getting started by Dirk Götz
 
Cucumber
CucumberCucumber
Cucumber
 
From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...
From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...
From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...
 
Supa fast Ruby + Rails
Supa fast Ruby + RailsSupa fast Ruby + Rails
Supa fast Ruby + Rails
 
Introduction To Rails
Introduction To RailsIntroduction To Rails
Introduction To Rails
 
Workin ontherailsroad
Workin ontherailsroadWorkin ontherailsroad
Workin ontherailsroad
 

Recently uploaded

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Recently uploaded (20)

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
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
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
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
 
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...
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 

Ruby - a tester's best friend

  • 1. Ruby - a tester’s best friend Peter Lind @peter_lind
  • 2. Ruby, wait what? Born in 1993 Object-oriented Dynamic Open Source Elegant syntax Focus on programmer happiness Great for scripting And for apps Ruby On Rails?
  • 3. Basics [array] {hash_key: hash_value} {hash_key => hash_value} do |var| <block body> end { |var| <block body> } class ClassName <class body> end def method_name <method body> end local_variable, @instance_variable, @@class_variable, Constant, $global
  • 4. Basics ruby script.rb IRB gems – gem install <library> rake – Rakefile
  • 5. How to install Use version 1.9.2 OSX / Linux – Might already have it – If not, use RVM • http://beginrescueend.com/rvm/install/ Windows – Use Railsinstaller • http://railsinstaller.org/
  • 6. Culture Ruby is your friend, not your parent
  • 7. Culture Ruby is your friend, not your parent Everything can be redefined
  • 8. Culture Ruby is your friend, not your parent Everything can be redefined Readability
  • 9. Culture Ruby is your friend, not your parent Everything can be redefined Readability
  • 10. Culture Ruby is your friend, not your parent Everything can be redefined Readability TDD/BDD
  • 11.
  • 12. Tools Sinatra – Sinatra is a DSL for quickly creating web applications in Ruby with minimal effort – http://www.sinatrarb.com/
  • 13.
  • 14.
  • 15.
  • 16. Tools Sinatra – Sinatra is a DSL for quickly creating web applications in Ruby with minimal effort – http://www.sinatrarb.com/ Cucumber – BDD that talks to domain experts first and code second – http://cukes.info/
  • 17. Cucumber Features – Describes scenarios – In the Gherkin language, almost English (or over 40 other) – Given, When, Then
  • 18.
  • 19. Cucumber Features – Describes scenarios – In the Gherkin language, almost English (or over 40 other) – Given, When, Then Step definitions – In Ruby – Available for Java, .NET others
  • 20.
  • 21. Tools Sinatra – Sinatra is a DSL for quickly creating web applications in Ruby with minimal effort – http://www.sinatrarb.com/ Cucumber – BDD that talks to domain experts first and code second – http://cukes.info/ Capybara – Acceptance test framework for web applications – https://github.com/jnicklas/capybara
  • 22. Cucumber and Capybara example http://www.youtube.com/watch?v=S5XQTOVTPYY https://github.com/peterlind/cuke4all
  • 24. pets.feature Pickle Feature: Manage pets Scenario: List pets Given a pet exists with name: "Fido", sort: 0, weight: 23 When I go to the list pets page Then I should see "Fido" Scenario: Enter a pet Capybara Given I am on the enter pet page And I fill in "Name" with "Rufus" And I fill in "Sort" with "Cat" And I fill in "Weight" with "8" And I press "Save" Then a pet should exist with name: "Rufus", weight: 8
  • 25.