TL; DR: "mock" and "stub" were the common terminology when RSpec's
API was first created but we've realized that using them
to create fake objects causes confusion and that
a much better term.
I wasn't around when RSpec's original APIs were created, so this is a bit of guess work, but here's my understanding.
When RSpec's mocking API was first created, the two common terms
used for what we now commonly call "test doubles" were mocks and
stubs. Mocking was a relatively new technique at the time, and the
terminology was still evolving. RSpec provided both
to create a fake object to use as a collaborator in your test.
However, mocks aren't
are different things. Furthermore, the mock vs stub distinction
isn't a property of the object, it's a property of an individual
method. That is, a test double can have some methods that have
been mocked (which RSpec will verify have been called at the end
of the example) and some methods that have been stubbed (which
return canned responses). Thus, I think it creates confusion
mock return a test double (which may in fact only have
stubbed methods and not be a mock at all).
Meanwhile, Gerard Meszaro later introduced the term "test double"
to provide a single, unified term for fake objects used as
stand-ins in place of real objects for testing. Martin
Fowler has a nice article on
double at some point after Meszaro's book
introduced the term. Since then,
been aliases for
double but there hasn't been a strong reason
to deprecate or remove them.
In RSpec 3 we're introducing some new types of doubles that
auto-verify the methods you mock or stub against a defined
interface, and we're calling these
class_double. We don't also want to have
and thought it would be odd to retain the
double without maintaning feature parity. So
we decided to deprecate them in preparation for RSpec 3.
Of course, while RSpec 3 no longer provides
double, it's easy to define these aliases on your
own if you'd like to keep using them:
module DoubleAliases def mock(*args, &block) double(*args, &block) end alias stub mock end RSpec.configure do |config| config.include DoubleAliases end