YEG-UG-Capybara
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
684
On Slideshare
684
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
1
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. AMIR BARYLKO INTRO TO CAPYBARA EDMONTON RUBY USER GROUP JUNE 2011Amir Barylko - Capybara MavenThought Inc.
  • 2. WHO AM I? • Architect • Developer • Mentor • Great cook • The one who’s entertaining you for the next hour!Amir Barylko - Capybara MavenThought Inc.
  • 3. BDDAmir Barylko - Capybara MavenThought Inc.
  • 4. WHY TRADITIONAL PROJECTS FAIL? • Delivering late or over budget • Delivering the wrong thing • Unstable in production • Costly to maintainAmir Barylko - Capybara MavenThought Inc.
  • 5. 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.
  • 6. OUTSIDE IN APPROACHAmir Barylko - Capybara MavenThought Inc.
  • 7. GHERKIN DSL • Business readable DSL • Flush out requirements • Documentation • Automated testing • Used by Cucumber, SpecFlow, jBehaveAmir Barylko - Capybara MavenThought Inc.
  • 8. CUCUMBERAmir Barylko - Capybara MavenThought Inc.
  • 9. 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.
  • 10. 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,...}) FakeWeb.register_uri(:get, "http://agilezen....", :body => fake_response) FakeWeb.register_uri(:get, "http://agilezen....", :body => JSON.generate(projects[0])) endAmir Barylko - Capybara MavenThought Inc.
  • 11. CAPYBARAAmir Barylko - Capybara MavenThought Inc.
  • 12. 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.
  • 13. 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.
  • 14. 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.
  • 15. 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.
  • 16. MATCHERS • has_selector? • has_no_selector? • has_content? • has_no_contentAmir Barylko - Capybara MavenThought Inc.
  • 17. 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.
  • 18. 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.
  • 19. 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.
  • 20. 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.
  • 21. QUESTIONS?Amir Barylko - Capybara MavenThought Inc.
  • 22. RESOURCES • Email: amir@barylko.com, • Twitter: @abarylko • Blog: http://orthocoders.com • Materials: http://orthocoders.com/presentations • Website: http://maventhought.comAmir Barylko - Capybara MavenThought Inc.
  • 23. 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.orgAmir Barylko - Capybara MavenThought Inc.