0
Full-StackIntegration Testing with RSpec-Steps          Evan Dorn  Founder, Logical Reality Design      http://LRDesign.co...
INTEGRATION  TESTING
INTEGRATION  TESTING     IS
INTEGRATION  TESTING     ISIMPORTANT!
ASSUMPTION:
ASSUMPTION:
ASSUMPTION:
WHAT WE WANT
WHAT WE WANT   •Full   Stack
WHAT WE WANT   •Full   Stack   •JavaScript
WHAT WE WANT   •Full   Stack   •JavaScript   •In-Browser
WHAT WE WANT   •Full   Stack   •JavaScript   •In-Browser   •Fail-Fast
TOOLS:
TOOLS:     RSpec   Capybara    Selenium  RSpec-StepsDatabase Cleaner
RSPEC PHILOSOPHY:
RSPEC PHILOSOPHY:  All tests / examples are  completely isolated and        independent!
RSPEC PHILOSOPHY:     All tests / examples are     completely isolated and           independent!    This is a problem for...
OPTION 1: Long examplesit “very long user story” do  # Log In  visit login_path  fill_in :login, “quentin”  click “Log In”...
OPTION 2: Repeat Yourselfit “should log in” do  visit login_path  fill_in :login, “quentin”  click “Log In”  page.should h...
OPTION 3: Cucumber!
OPTION 3: Cucumber!
INTRODUCING: RSpec-Steps steps “neat user story” do   it “should log in” do     visit login_path     fill_in :login, “quen...
Using RSpec-Steps# Gemfilegem ‘rspec-steps’
NEXT PROBLEM: Database Transactionsrequire ‘capybara’it “should log in”, :type => :request do  user = Factory(:user)  visi...
Won’t Work!Factor y() and request are in different transactions!
SOLUTION:    DatabaseCleaner# Gemfilegem ‘database-cleaner’
SOLUTION:       DatabaseCleaner# spec_helper.rbconfig.use_transactional_fixtures = :falseconfig.after :all, :type => :requ...
Thanks! https://github.com/LRDesign/rspec-stepshttps://gist.github.com/1141135 (example)
2011-08-11 Full Stack Integration Testing with RSpec-Steps
2011-08-11 Full Stack Integration Testing with RSpec-Steps
2011-08-11 Full Stack Integration Testing with RSpec-Steps
2011-08-11 Full Stack Integration Testing with RSpec-Steps
2011-08-11 Full Stack Integration Testing with RSpec-Steps
2011-08-11 Full Stack Integration Testing with RSpec-Steps
Upcoming SlideShare
Loading in...5
×

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

2,604

Published 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 stack uses RSpec, augmented by our gem RSpec-Steps, and capybara/selenium.

Published in: Technology, Business
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,604
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
20
Comments
0
Likes
1
Embeds 0
No embeds

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 of "2011-08-11 Full Stack Integration Testing with RSpec-Steps"

    1. 1. Full-StackIntegration Testing with RSpec-Steps Evan Dorn Founder, Logical Reality Design http://LRDesign.com evan@LRDesign.com
    2. 2. INTEGRATION TESTING
    3. 3. INTEGRATION TESTING IS
    4. 4. INTEGRATION TESTING ISIMPORTANT!
    5. 5. ASSUMPTION:
    6. 6. ASSUMPTION:
    7. 7. ASSUMPTION:
    8. 8. WHAT WE WANT
    9. 9. WHAT WE WANT •Full Stack
    10. 10. WHAT WE WANT •Full Stack •JavaScript
    11. 11. WHAT WE WANT •Full Stack •JavaScript •In-Browser
    12. 12. WHAT WE WANT •Full Stack •JavaScript •In-Browser •Fail-Fast
    13. 13. TOOLS:
    14. 14. TOOLS: RSpec Capybara Selenium RSpec-StepsDatabase Cleaner
    15. 15. RSPEC PHILOSOPHY:
    16. 16. RSPEC PHILOSOPHY: All tests / examples are completely isolated and independent!
    17. 17. RSPEC PHILOSOPHY: All tests / examples are completely isolated and independent! This is a problem forintegration testing / stories.
    18. 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. 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. 20. OPTION 3: Cucumber!
    21. 21. OPTION 3: Cucumber!
    22. 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. 23. Using RSpec-Steps# Gemfilegem ‘rspec-steps’
    24. 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. 25. Won’t Work!Factor y() and request are in different transactions!
    26. 26. SOLUTION: DatabaseCleaner# Gemfilegem ‘database-cleaner’
    27. 27. SOLUTION: DatabaseCleaner# spec_helper.rbconfig.use_transactional_fixtures = :falseconfig.after :all, :type => :request do DatabaseCleaner.clean_with :truncation load db/seeds.rbend
    28. 28. Thanks! https://github.com/LRDesign/rspec-stepshttps://gist.github.com/1141135 (example)
    1. A particular slide catching your eye?

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

    ×