RSPEC on Rails




@skorfmann & @jeremy

Rspec?


  • Testing Framework
  • Behaviour Driven Development
  • Testing DSL
  • Rich ecosystem

RSPEC Rails TEst Types


  • controllers
  • models
  • views
  • routing
  • requests
  • features

Controllers


Test the behaviour

  • status / redirect
  • authenticated / authorized

  • Bypasses routing
  • Doesn't render views

Models


  • unit tests
  • isolated
  • behaviour

  • NOT:  ActiveRecord

Views

Test complicated views

  • Stateful views
  • In isolation
  • HTML / RSS / JSON / XML

Routing


  • namespaces / modules
  • special params
  • not accessible routes

Requests


  • Wraps Rails integration test
  • Test the full stack
  • Includes routing layer

Features


Actual Integration test

  • headless browser
  • real interaction
  • pretty slow
  • happy path tests

Testing External Dependencies



  • HTTP / APIs
  • Time
  • Filesystem

Testing Internal Dependencies



Jeremy: Mocking / Stubbing

RSPEC on Rails

By skorfmann

RSPEC on Rails

  • 775