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

TDD Talk Slides

Damir
December 29, 2015
46

TDD Talk Slides

A short overview of various test double helpers provided by RSpec

Damir

December 29, 2015
Tweet

Transcript

  1. double A simple object that stands in place of any

    other object. (Think of stunt doubles)
  2. instance_double A simple object that stands in place of an

    object. It verifies that the described double matches the object it stands for. (Verifying double)
  3. mock_model A test double object expanded with ActiveModel and ActiveRecord

    API. Includes real functionality of AM/AR methods. Good for testing interactions with AR/AM objects.
  4. stub_model The real AR/AM object, with some mechanisms stubbed. Builds

    on top of the existing models, uses the real app code. Good for state-based tests. WARNING: In some cases can result in the actual DB calls.
  5. build_stubbed The real AR object that's build with FactoryGirl. If

    FactoryGirl defines dependencies they will be created. Only persistence mechanisms are stubbed.