2011-08-11 Full Stack Integration Testing with RSpec-Steps

  • 2,468 views
Uploaded on

August 11, 2011. This presentation (lightning talk at the LA Ruby Meetup) demonstrates how to test your Rails app in-browser, full stack including javascript, without using cucumber. The testing …

August 11, 2011. This presentation (lightning talk at the LA Ruby Meetup) demonstrates how to test your Rails app in-browser, full stack including javascript, without using cucumber. The testing stack uses RSpec, augmented by our gem RSpec-Steps, and capybara/selenium.

More in: Technology , Business
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
2,468
On Slideshare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
17
Comments
0
Likes
1

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
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

Transcript

  • 1. Full-StackIntegration Testing with RSpec-Steps Evan Dorn Founder, Logical Reality Design http://LRDesign.com evan@LRDesign.com
  • 2. INTEGRATION TESTING
  • 3. INTEGRATION TESTING IS
  • 4. INTEGRATION TESTING ISIMPORTANT!
  • 5. ASSUMPTION:
  • 6. ASSUMPTION:
  • 7. ASSUMPTION:
  • 8. WHAT WE WANT
  • 9. WHAT WE WANT •Full Stack
  • 10. WHAT WE WANT •Full Stack •JavaScript
  • 11. WHAT WE WANT •Full Stack •JavaScript •In-Browser
  • 12. WHAT WE WANT •Full Stack •JavaScript •In-Browser •Fail-Fast
  • 13. TOOLS:
  • 14. TOOLS: RSpec Capybara Selenium RSpec-StepsDatabase Cleaner
  • 15. RSPEC PHILOSOPHY:
  • 16. RSPEC PHILOSOPHY: All tests / examples are completely isolated and independent!
  • 17. RSPEC PHILOSOPHY: All tests / examples are completely isolated and independent! This is a problem forintegration testing / stories.
  • 18. OPTION 1: Long examplesit “very long user story” do # Log In visit login_path fill_in :login, “quentin” click “Log In” page.should have_text(“Welcome, Quentin!”) # Update Profile click “Update Profile” page.should have_css(“form#edit_account”) # More shit ... another 100 lines & 20 requests ...end
  • 19. OPTION 2: Repeat Yourselfit “should log in” do visit login_path fill_in :login, “quentin” click “Log In” page.should have_text(“Welcome, Quentin!”)endit “should log in and load profile form” do visit login_path ... etc ... click “Update Profile” page.should have_css(“form#edit_account”)endit “should log in AND load form AND update profile” doend
  • 20. OPTION 3: Cucumber!
  • 21. OPTION 3: Cucumber!
  • 22. INTRODUCING: RSpec-Steps steps “neat user story” do it “should log in” do visit login_path fill_in :login, “quentin” click “Log In” page.should have_text(“Welcome, Quentin!”) end it “should load profile form do” click “Update Profile” page.should have_css(“form#edit_account”) end it “etc ... more steps” do end end
  • 23. Using RSpec-Steps# Gemfilegem ‘rspec-steps’
  • 24. NEXT PROBLEM: Database Transactionsrequire ‘capybara’it “should log in”, :type => :request do user = Factory(:user) visit login_path fill_in :name, user.name click “Login”end
  • 25. Won’t Work!Factor y() and request are in different transactions!
  • 26. SOLUTION: DatabaseCleaner# Gemfilegem ‘database-cleaner’
  • 27. SOLUTION: DatabaseCleaner# spec_helper.rbconfig.use_transactional_fixtures = :falseconfig.after :all, :type => :request do DatabaseCleaner.clean_with :truncation load db/seeds.rbend
  • 28. Thanks! https://github.com/LRDesign/rspec-stepshttps://gist.github.com/1141135 (example)