Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Testing with Rspec on Rails

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest. →

Testing with Rspec on Rails

Introduction to Testing

Avatar for Shinn Chong

Shinn Chong

July 16, 2014

Other Decks in Programming

Transcript

  1. Why testing? • Delivery with confident • Know your application

    flow • Regression testing • Leads to a more manageable codebase • YOLO!
  2. Feature specs • AKA Integration Testing • AKA Acceptance Testing

    • AKA End-to-end testing • Walk through your entire application • Fully automated with Capybara • features/ with RSpec
  3. Controller specs • Testing for multiple paths • Check for

    invalid variables in the controller • Easier to write
  4. Routing specs • Write tests for route.rb • To test

    the available routes • Especially useful for large application • Easiest to implement
  5. Factories • Factory Girl • Fixtures replacement • Setting up

    Ruby objects as test data • Good for building multiple strategies • saved instances (create) • unsaved instance (build) • attribute hashes (attributes_for) • Alternatively, Fabrication
  6. Tools • Guard • Faker • Capybara • selenium /

    capybara-webkit • database_cleaner • shoulda-matchers • spring / zeus / spork