Capybara1
Upcoming SlideShare
Loading in...5
×
 

Capybara1

on

  • 682 views

 

Statistics

Views

Total Views
682
Views on SlideShare
682
Embed Views
0

Actions

Likes
0
Downloads
8
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Capybara1 Capybara1 Presentation Transcript

  • AMIR BARYLKO INTRO TO CAPYBARA RUBY UG NOV 2010Amir Barylko - Capybara MavenThought Inc.Thursday, November 25, 2010
  • WHO AM I? • Architect • Developer • Mentor • Great cook • The one who’s entertaining you for the next hour!Amir Barylko - Capybara MavenThought Inc.Thursday, November 25, 2010
  • BDDAmir Barylko - Capybara MavenThought Inc.Thursday, November 25, 2010
  • WHY TRADITIONAL PROJECTS FAIL? • Delivering late or over budget • Delivering the wrong thing • Unstable in production • Costly to maintainAmir Barylko - Capybara MavenThought Inc.Thursday, November 25, 2010
  • BDD PRINCIPLES • Behaviour Driven development is about implementing an application by describing its behaviour from the perspective of the stakeholder • Enough is Enough • Deliver stakeholder value • It’s all behaviourAmir Barylko - Capybara MavenThought Inc.Thursday, November 25, 2010
  • OUTSIDE IN APPROACHAmir Barylko - Capybara MavenThought Inc.Thursday, November 25, 2010
  • GHERKIN DSL • Business readable DSL • Flush out requirements • Documentation • Automated testing • Used by Cucumber, SpecFlow, jBehaveAmir Barylko - BDD MavenThought Inc.Thursday, November 25, 2010
  • CUCUMBERAmir Barylko - Capybara MavenThought Inc.Thursday, November 25, 2010
  • FEATURES Feature: Listing projects As a user I Want to see the list of projects So I can choose one to see the details Scenario: List all projects Given Im logged in And I have the projects: | Caruso | | Pucini | | Mariachi | When I go to the projects page Then I should see "Caruso" And I should see "Pucini" And I should see "Mariachi"Amir Barylko - Capybara MavenThought Inc.Thursday, November 25, 2010
  • STEPS Given /^I have the projects:$/ do |table| projects = table.raw.collect do |project| {"id" => 4444, "name" => "#{project}", "description" => "Project developed in rails", "createTime" => "/Date(1256774726000-0500)/", "owner" => {"id" => 2222,"name" => "Some user"}} end fake_response = JSON.generate({"page" => 1,"pageSize" => 10,"totalPages" => 1,"totalItems" => 1, "items" => projects}) FakeWeb.register_uri(:get, "http://agilezen.com/api/v1/projects", :body => fake_response) FakeWeb.register_uri(:get, "http://agilezen.com/api/v1/project/4444", :body => JSON.generate(projects[0])) endAmir Barylko - Capybara MavenThought Inc.Thursday, November 25, 2010
  • CAPYBARAAmir Barylko - Capybara MavenThought Inc.Thursday, November 25, 2010
  • WHAT • Gem to simplify integration tests • Inspired by Webrat • Can be used with Cucumber steps or in any other test • Easy to install: gem install capybaraAmir Barylko - Capybara MavenThought Inc.Thursday, November 25, 2010
  • WHY • Support for different web browsers • Provides driver to run headless (without browser) • Can combine different scenarios with different browsers • Supports Rack and any remote web application • Supports asynchronous callsAmir Barylko - Capybara MavenThought Inc.Thursday, November 25, 2010
  • FORMS • click_link(...) • check(...) • click_button(...) • uncheck(...) • click_link_or_button(...) • attach_file(...) • choose(...) • select_option(...) • fill_in(“FirstName”, :with => “John”)Amir Barylko - Capybara MavenThought Inc.Thursday, November 25, 2010
  • FINDERS • all(*args) • find_button • page.all(:css, ‘a#user’) • find_by_id • page.all(:xpath, ‘//[@id=user]’) • find (same args as all) • find_field • find_linkAmir Barylko - Capybara MavenThought Inc.Thursday, November 25, 2010
  • MATCHERS • has_selector? • has_no_selector? • has_content? • has_no_contentAmir Barylko - Capybara MavenThought Inc.Thursday, November 25, 2010
  • STEPS • Given I am on Home • When I go to Projects • When I press “login” within “user” • When I follow “help” within “support”Amir Barylko - Capybara MavenThought Inc.Thursday, November 25, 2010
  • STEPS II • When I fill “username” with “mel” • When I select “Winnipeg” from “cities” • When I check “remember_me” • When I uncheck “remember_me” • When I choose “Option” • When I attach then file “settings.xml” to “file”Amir Barylko - Capybara MavenThought Inc.Thursday, November 25, 2010
  • STEPS III • Then I should see “Welcome” • Then I should not see “Welcome” • Then the field “user” should contain “Mel” • Then show me the pageAmir Barylko - Capybara MavenThought Inc.Thursday, November 25, 2010
  • XPATH • Then I should see “Welcome” • Then I should not see “Welcome” • Then the field “user” should contain “Mel” • Then show me the pageAmir Barylko - Capybara MavenThought Inc.Thursday, November 25, 2010
  • QUESTIONS?Amir Barylko - Capybara MavenThought Inc.Thursday, November 25, 2010
  • RESOURCES • Contact me: amir@barylko.com, @abarylko • Materials: http://www.orthocoders.com/presentationsAmir Barylko - Capybara MavenThought Inc.Thursday, November 25, 2010
  • RESOURCES II • Capybara: https://github.com/jnicklas/capybara • Cucumber: https://github.com/aslakhellesoy/cucumber/wiki/ • Culerity: https://github.com/langalex/culerity • Celerity: http://celerity.rubyforge.org/ • Selenium: http://seleniumhq.org/Amir Barylko - Capybara MavenThought Inc.Thursday, November 25, 2010