CapybaraAlmir M3nd3s                Flávia Missi@m3nd3s                    @flaviamissialmirmendes.com      flaviamissi.co...
Unit testsFunctional test
User + Browser
Integration tests
http://www.flickr.com/photos/kalebdf/3172638676/   Ué... nãoaconteceu nada! Capybara simulates how a real    user would in...
Sinatra
Selenium HQ
gem install capybara
spec_helper.rb require capybara/rails require capybara/rspec
Capybara.default_driver = :seleniumCapybara.register_driver :selenium do |app|    Capybara::Driver::Selenium.new(    app, ...
visit(/projects)visit(post_comments_path(post))         current_path
Simulating click
click_link(id-of-link)          click_link(Link Text) click_button(Save)              click_on(Link Text)click_on(Button V...
Filling html forms
fill_in(First Name, :with => John)        choose(A Radio Button)           check(A Checkbox)         uncheck(A Checkbox)at...
within("li#employee") do fill_in Name, :with => Jimmyendwithin(:xpath, "//li[@id=employee]") do fill_in Name, :with => Jim...
Queryingpage.has_selector?(table tr)page.has_selector?(:xpath, //table/tr)page.has_no_selector?(:content)page.has_xpath?(/...
RSpec Queryingpage.should have_selector(table tr)page.should have_selector(:xpath, //table/tr)page.should have_no_selector...
Valeu!   É nozes!
Linkshttp://rubydoc.info/github/jnicklas/capybara/master/file/README.rdochttps://github.com/jnicklas/capybara
Capybara
Upcoming SlideShare
Loading in …5
×

Capybara

3,534 views

Published on

Presentation about Integration Tests using Capybara, Selenium and Rails.

Published in: Technology
0 Comments
6 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,534
On SlideShare
0
From Embeds
0
Number of Embeds
435
Actions
Shares
0
Downloads
31
Comments
0
Likes
6
Embeds 0
No embeds

No notes for slide

Capybara

  1. 1. CapybaraAlmir M3nd3s Flávia Missi@m3nd3s @flaviamissialmirmendes.com flaviamissi.com.br
  2. 2. Unit testsFunctional test
  3. 3. User + Browser
  4. 4. Integration tests
  5. 5. http://www.flickr.com/photos/kalebdf/3172638676/ Ué... nãoaconteceu nada! Capybara simulates how a real user would interact with a web application
  6. 6. Sinatra
  7. 7. Selenium HQ
  8. 8. gem install capybara
  9. 9. spec_helper.rb require capybara/rails require capybara/rspec
  10. 10. Capybara.default_driver = :seleniumCapybara.register_driver :selenium do |app| Capybara::Driver::Selenium.new( app, :browser => :chrome) end
  11. 11. visit(/projects)visit(post_comments_path(post)) current_path
  12. 12. Simulating click
  13. 13. click_link(id-of-link) click_link(Link Text) click_button(Save) click_on(Link Text)click_on(Button Value)
  14. 14. Filling html forms
  15. 15. fill_in(First Name, :with => John) choose(A Radio Button) check(A Checkbox) uncheck(A Checkbox)attach_file(Image, /path/to/image.jpg) select(Option, :from => Select Box)
  16. 16. within("li#employee") do fill_in Name, :with => Jimmyendwithin(:xpath, "//li[@id=employee]") do fill_in Name, :with => Jimmyend
  17. 17. Queryingpage.has_selector?(table tr)page.has_selector?(:xpath, //table/tr)page.has_no_selector?(:content)page.has_xpath?(//table/tr)page.has_css?(table tr.foo)page.has_content?(foo)
  18. 18. RSpec Queryingpage.should have_selector(table tr)page.should have_selector(:xpath, //table/tr)page.should have_no_selector(:content)page.should have_xpath(//table/tr)page.should have_css(table tr.foo)page.should have_content(foo)page.should have_no_content(foo)
  19. 19. Valeu! É nozes!
  20. 20. Linkshttp://rubydoc.info/github/jnicklas/capybara/master/file/README.rdochttps://github.com/jnicklas/capybara

×