(Testing Rails Notes) Types of tests, when to use them, and some useful gems

Posted Almost 7 years ago. Visible to the public.

From Testing Rails book...

FEATURE/ACCEPTANCE:

  • Check the happy paths
  • Expensive so use sparingly

REQUEST:

  • These are like feature tests, they go through router, render content, etc. More expensive than Controller specs.

CONTROLLER

  • good to check 'Sad Paths'
  • you can assert against an actual response object, but not check content rendered

VIEW & HELPER:

  • Test a little piece of logic you have. Cheaper than feature spec, etc.

MODEL:

  • Unit tests

Useful Gems:

  • email-spec (https://github.com/email-spec/email-spec)
  • shoulda-matchers (https://github.com/thoughtbot/shoulda-matchers) for validation testing on models
Greg
Last edit
Almost 7 years ago
Greg
Tags
Posted by Greg to Ruby on Rails (2017-07-06 13:12)