Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
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
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/
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/
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