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

on

  • 3,011 views

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.

Statistics

Views

Total Views
3,011
Views on SlideShare
3,007
Embed Views
4

Actions

Likes
1
Downloads
17
Comments
0

3 Embeds 4

http://www.hanrss.com 2
http://localhost 1
http://www.docshut.com 1

Accessibility

Upload Details

Uploaded via as Apple Keynote

Usage Rights

CC Attribution-NoDerivs LicenseCC Attribution-NoDerivs License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • \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

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

  • Full-StackIntegration Testing with RSpec-Steps Evan Dorn Founder, Logical Reality Design http://LRDesign.com evan@LRDesign.com
  • 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 forintegration testing / stories.
  • 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
  • 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
  • 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, “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
  • Using RSpec-Steps# Gemfilegem ‘rspec-steps’
  • 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
  • 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 => :request do DatabaseCleaner.clean_with :truncation load db/seeds.rbend
  • Thanks! https://github.com/LRDesign/rspec-stepshttps://gist.github.com/1141135 (example)