JUST SO THAT WE CAN UNDERSTAND EACH OTHER...
What is a TEST OBJECT?
Test object is an umbrella term for any object created with a purpose of replacing a real object within a test suite.
Its interface is susceptible to being stubbed and modified as needed by the test example.
What is a STUB?
Dictionary defines stub as:
a truncated or unusually short thing: he wagged his little stub of tail.
What does that mean for a Ruby developer?
Stub is a replacement method on a test object that gets invoked instead of the authentic method.
Stub is not an object (unless you take into account that methods are object, but will not help us to clarify things).
What is a (TEST) DOUBLE?
It is a the simplest type of a test object that can be stubbed and used in different contexts, hence can become a different type of test object.
Basically, he exists "instead of" some other real object.
What is a REAL OBJECT?
Real object is an umbrella term for any object that is a part of the actual application codebase (that excludes test suite).
It can be a class, module or an instance.
What is a MOCK?
Mock is a test object created with a purpose of testing behaviour. Meaning, that a certain message gets sent.
Dictionary defines it as:
(mock something up) make a replica or imitation of something.
What does that mean for a Ruby developer?
Objects present in test suite
TEST OBJECTS
REAL OBJECTS
classes
modules
instances
double
spy
Verifying
double
class
double
instance
double
object
double
partial
double
verifying
partial
double
RSpec Mocks
By Dario Daic
RSpec Mocks
- 529