yeg-ug-capybara
DESCRIPTION
TRANSCRIPT
![Page 1: YEG-UG-Capybara](https://reader033.vdocument.in/reader033/viewer/2022042813/54579e78af79590b088b51a5/html5/thumbnails/1.jpg)
Amir Barylko - Capybara MavenThought Inc.
AMIR BARYLKO
INTRO TOCAPYBARA
EDMONTON RUBY USER GROUPJUNE 2011
![Page 2: YEG-UG-Capybara](https://reader033.vdocument.in/reader033/viewer/2022042813/54579e78af79590b088b51a5/html5/thumbnails/2.jpg)
Amir Barylko - Capybara MavenThought Inc.
WHO AM I?
• Architect
• Developer
• Mentor
• Great cook
• The one who’s entertaining you for the next hour!
![Page 3: YEG-UG-Capybara](https://reader033.vdocument.in/reader033/viewer/2022042813/54579e78af79590b088b51a5/html5/thumbnails/3.jpg)
Amir Barylko - Capybara MavenThought Inc.
BDD
![Page 4: YEG-UG-Capybara](https://reader033.vdocument.in/reader033/viewer/2022042813/54579e78af79590b088b51a5/html5/thumbnails/4.jpg)
Amir Barylko - Capybara MavenThought Inc.
WHY TRADITIONALPROJECTS FAIL?
• Delivering late or over budget
• Delivering the wrong thing
• Unstable in production
• Costly to maintain
![Page 5: YEG-UG-Capybara](https://reader033.vdocument.in/reader033/viewer/2022042813/54579e78af79590b088b51a5/html5/thumbnails/5.jpg)
Amir Barylko - Capybara MavenThought Inc.
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 behaviour
![Page 6: YEG-UG-Capybara](https://reader033.vdocument.in/reader033/viewer/2022042813/54579e78af79590b088b51a5/html5/thumbnails/6.jpg)
Amir Barylko - Capybara MavenThought Inc.
OUTSIDE IN APPROACH
![Page 7: YEG-UG-Capybara](https://reader033.vdocument.in/reader033/viewer/2022042813/54579e78af79590b088b51a5/html5/thumbnails/7.jpg)
Amir Barylko - Capybara MavenThought Inc.
GHERKIN DSL
• Business readable DSL
• Flush out requirements
• Documentation
• Automated testing
• Used by Cucumber, SpecFlow, jBehave
![Page 8: YEG-UG-Capybara](https://reader033.vdocument.in/reader033/viewer/2022042813/54579e78af79590b088b51a5/html5/thumbnails/8.jpg)
Amir Barylko - Capybara MavenThought Inc.
CUCUMBER
![Page 9: YEG-UG-Capybara](https://reader033.vdocument.in/reader033/viewer/2022042813/54579e78af79590b088b51a5/html5/thumbnails/9.jpg)
Amir Barylko - Capybara MavenThought Inc.
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 I'm 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"
![Page 10: YEG-UG-Capybara](https://reader033.vdocument.in/reader033/viewer/2022042813/54579e78af79590b088b51a5/html5/thumbnails/10.jpg)
Amir Barylko - Capybara MavenThought Inc.
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]))
end
![Page 11: YEG-UG-Capybara](https://reader033.vdocument.in/reader033/viewer/2022042813/54579e78af79590b088b51a5/html5/thumbnails/11.jpg)
Amir Barylko - Capybara MavenThought Inc.
CAPYBARA
![Page 12: YEG-UG-Capybara](https://reader033.vdocument.in/reader033/viewer/2022042813/54579e78af79590b088b51a5/html5/thumbnails/12.jpg)
Amir Barylko - Capybara MavenThought Inc.
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 capybara
![Page 13: YEG-UG-Capybara](https://reader033.vdocument.in/reader033/viewer/2022042813/54579e78af79590b088b51a5/html5/thumbnails/13.jpg)
Amir Barylko - Capybara MavenThought Inc.
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 calls
![Page 14: YEG-UG-Capybara](https://reader033.vdocument.in/reader033/viewer/2022042813/54579e78af79590b088b51a5/html5/thumbnails/14.jpg)
Amir Barylko - Capybara MavenThought Inc.
FORMS
• click_link(...)
• click_button(...)
• click_link_or_button(...)
• choose(...)
• fill_in(“FirstName”, :with => “John”)
• check(...)
• uncheck(...)
• attach_file(...)
• select_option(...)
![Page 15: YEG-UG-Capybara](https://reader033.vdocument.in/reader033/viewer/2022042813/54579e78af79590b088b51a5/html5/thumbnails/15.jpg)
Amir Barylko - Capybara MavenThought Inc.
FINDERS
• all(*args)• page.all(:css, ‘a#user’)
• page.all(:xpath, ‘//[@id=user]’)
• find (same args as all)
• find_field
• find_link
• find_button
• find_by_id
![Page 16: YEG-UG-Capybara](https://reader033.vdocument.in/reader033/viewer/2022042813/54579e78af79590b088b51a5/html5/thumbnails/16.jpg)
Amir Barylko - Capybara MavenThought Inc.
MATCHERS
• has_selector?
• has_no_selector?
• has_content?
• has_no_content
![Page 17: YEG-UG-Capybara](https://reader033.vdocument.in/reader033/viewer/2022042813/54579e78af79590b088b51a5/html5/thumbnails/17.jpg)
Amir Barylko - Capybara MavenThought Inc.
STEPS
• Given I am on Home
• When I go to Projects
• When I press “login” within “user”
• When I follow “help” within “support”
![Page 18: YEG-UG-Capybara](https://reader033.vdocument.in/reader033/viewer/2022042813/54579e78af79590b088b51a5/html5/thumbnails/18.jpg)
Amir Barylko - Capybara MavenThought Inc.
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”
![Page 19: YEG-UG-Capybara](https://reader033.vdocument.in/reader033/viewer/2022042813/54579e78af79590b088b51a5/html5/thumbnails/19.jpg)
Amir Barylko - Capybara MavenThought Inc.
STEPS III
• Then I should see “Welcome”
• Then I should not see “Welcome”
• Then the field “user” should contain “Mel”
• Then show me the page
![Page 20: YEG-UG-Capybara](https://reader033.vdocument.in/reader033/viewer/2022042813/54579e78af79590b088b51a5/html5/thumbnails/20.jpg)
Amir Barylko - Capybara MavenThought Inc.
XPATH
• Then I should see “Welcome”
• Then I should not see “Welcome”
• Then the field “user” should contain “Mel”
• Then show me the page
![Page 21: YEG-UG-Capybara](https://reader033.vdocument.in/reader033/viewer/2022042813/54579e78af79590b088b51a5/html5/thumbnails/21.jpg)
Amir Barylko - Capybara MavenThought Inc.
QUESTIONS?
![Page 22: YEG-UG-Capybara](https://reader033.vdocument.in/reader033/viewer/2022042813/54579e78af79590b088b51a5/html5/thumbnails/22.jpg)
Amir Barylko - Capybara MavenThought Inc.
RESOURCES
• Email: [email protected],
• Twitter : @abarylko
• Blog: http://orthocoders.com
• Materials: http://orthocoders.com/presentations
• Website: http://maventhought.com
![Page 23: YEG-UG-Capybara](https://reader033.vdocument.in/reader033/viewer/2022042813/54579e78af79590b088b51a5/html5/thumbnails/23.jpg)
Amir Barylko - Capybara MavenThought Inc.
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