Integration Test With Cucumber And Webrat

5,334
-1

Published on

my talk about cucumber and webrat on ruby tuesday

Published in: Self Improvement
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
5,334
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
50
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Integration Test With Cucumber And Webrat

  1. 1. Integration Test with Cucumber and Webrat Kang-min Liu gugod@gugod.org
  2. 2. Integration Test • • • Web App:
  3. 3. : twitter
  4. 4. : twitter 1. http://twitter.com/home 2. status 3. update 4.
  5. 5. Webrat visit "http://twitter.com/home" fill_in "status", :with => "lorem ipsum" click_button "update" response.body.should =~ /lorem ipsum/
  6. 6. Webrat Browser emulation / control
  7. 7. Webrat • • • •
  8. 8. Webrat • javascript • css
  9. 9. Webrat • • Selenium • Watir
  10. 10. Webrat Core API • visit • select • click_link • attach_file • fill_in • click_button • check • uncheck • choose
  11. 11. Webrat Core API • visit, click_link • get + assert_response :success • click_button • submit form + assert_response :success • submit form default values if any
  12. 12. Webrat + RSpec describe "tweeting" do it "should show my tweets" do visit "/home" fill_in "status", :with => "lorem ipsum" click_button "update" response.body.should =~ /lorem ipsum/ end end
  13. 13. ?
  14. 14. Goods • • HTML •
  15. 15. Cucumber • BDD (Behavior Driven Development) Tool • Ruby implementation • •
  16. 16. Feature: Update my status In order to keep friends posted As a friendly person I post my status to twitter Scenario: Update my status Given I go to “/home” When I fill in “status” with “lorem ipsum” And I click “send” Then I should see “lorem ipsum”
  17. 17. Feature: Update my status In order to keep friends posted As a friendly person I post my status to twitter Scenario: Update my status Given I go to “/home” When I fill in “status” with “lorem ipsum” And I click “send” Then I should see “lorem ipsum”
  18. 18. Feature: Update my status In order to keep friends posted As a friendly person I post my status to twitter Scenario: Update my status Given I go to “/home” When I fill in “status” with “lorem ipsum” And I click “send” Then I should see “lorem ipsum”
  19. 19. Scenario: Update my status Given I go to “/home” When I fill in “status” with “lorem ipsum” And I click “send” Then I should see “lorem ipsum” Given – When – Then –
  20. 20. Given /^I go to "(.*)"$/ do |url| visit url end When /^I fill in "(.*)" with "(.*)"$/ do |field,value| fill_in field, :with => value end When /^I click "(.*)"$/ do |link| click_link(link) end Then /^I should see "(.*)"$/ do |text| response.body.should =~ /#{text}/m end
  21. 21. ?
  22. 22. Goods... • • • •
  23. 23. Goods... • •
  24. 24. Scenario: Update my status Given I go to “/home” When I fill in “status” with “lorem ipsum” And I click “send” Then I should see “lorem ipsum”
  25. 25. describe "tweeting" do it "should show my tweets" do visit "/home" fill_in "status", :with => "lorem ipsum" click_button "update" response.body.should =~ /lorem ipsum/ end end
  26. 26. Reference • Cucumber http://cukes.info/ • Webrat http://github.com/brynary/webrat/ tree/master • Test::Cukes http://search.cpan.org/dist/Test- Cukes/ (Perl implementation)
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×