Spec Types

For the expense tracker API you built in this book, you wrote three different kinds of specs:

  • Acceptance specs to test the entire app end to end
  • Unit specs to test one layer in isolation
  • Integration specs to test objects with real collaborators and external services

A Rails app is more complex than a tiny API. Accordingly, Rails provides infrastructure for several different kinds of tests, including the following ones:

  • Integration tests that drive your app as a black box via its HTTP interface
  • Functional tests to see how your controllers respond to requests
  • Unit tests to drive a single object or layer
  • Specific tests for models, mailers, and background jobs; any given test here may be a unit or integration test

To test one of these aspects ...

Get Effective Testing with RSpec 3 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.