26
Ruby - a tester’s best friend Peter Lind @peter_lind

Ruby - a tester's best friend

Embed Size (px)

Citation preview

Page 1: Ruby - a tester's best friend

Ruby - a tester’s best friendPeter Lind @peter_lind

Page 2: Ruby - a tester's best friend

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?

Page 3: Ruby - a tester's best friend

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

Page 4: Ruby - a tester's best friend

Basics

ruby script.rb

IRB

gems– gem install <library>

rake– Rakefile

Page 5: Ruby - a tester's best friend

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/

Page 6: Ruby - a tester's best friend

Culture

Ruby is your friend, not your parent

Page 7: Ruby - a tester's best friend

Culture

Ruby is your friend, not your parent

Everything can be redefined

Page 8: Ruby - a tester's best friend

Culture

Ruby is your friend, not your parent

Everything can be redefined

Readability

Page 9: Ruby - a tester's best friend

Culture

Ruby is your friend, not your parent

Everything can be redefined

Readability

Page 10: Ruby - a tester's best friend

Culture

Ruby is your friend, not your parent

Everything can be redefined

Readability

TDD/BDD

Page 11: Ruby - a tester's best friend
Page 12: Ruby - a tester's best friend

Tools

Sinatra– Sinatra is a DSL for quickly creating web applications in Ruby

with minimal effort– http://www.sinatrarb.com/

Page 13: Ruby - a tester's best friend
Page 14: Ruby - a tester's best friend
Page 15: Ruby - a tester's best friend
Page 16: Ruby - a tester's best friend

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/

Page 17: Ruby - a tester's best friend

Cucumber

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

Page 18: Ruby - a tester's best friend
Page 19: Ruby - a tester's best friend

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

Page 20: Ruby - a tester's best friend
Page 21: Ruby - a tester's best friend

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

Page 22: Ruby - a tester's best friend

Cucumber and Capybara example

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

https://github.com/peterlind/cuke4all

Page 23: Ruby - a tester's best friend

Java Web App

Tests

Page 24: Ruby - a tester's best friend

pets.featureFeature: 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 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

Capybara

Pickle

Page 25: Ruby - a tester's best friend
Page 26: Ruby - a tester's best friend

THANKS!

[email protected]@peter_lind