2.14.0 / 2013-07-06
Enhancements:
- Document test spies in the readme. (Adarsh Pandit)
- Add an
array_including
matcher. (Sam Phippen) - Add a syntax-agnostic API for mocking or stubbing a method. This is
intended for use by libraries such as rspec-rails that need to mock
or stub a method, and work regardless of the syntax the user has
configured (Paul Annesley, Myron Marston and Sam Phippen).
Bug Fixes:
- Fix
double
so that it sets up passed stubs correctly regardless of
the configured syntax (Paul Annesley). - Allow a block implementation to be used in combination with
and_yield
,and_raise
,and_return
orand_throw
. This got fixed
in 2.13.1 but failed to get merged into master for the 2.14.0.rc1
release (Myron Marston). Marshal.dump
does not unnecessarily duplicate objects when rspec-mocks has
not been fully initialized. This could cause errors when usingspork
or
similar preloading gems (Andy Lindeman).
2.14.0.rc1 / 2013-05-27
Enhancements:
- Refactor internals so that the mock proxy methods and state are held
outside of the mocked object rather than inside it. This paves the way
for future syntax enhancements and removes the need for some hacky
work arounds forany_instance
dup'ing andYAML
serialization,
among other things. Note that the code now relies upon__id__
returning a unique, consistent value for any object you want to
mock or stub (Myron Marston). - Add support for test spies. This allows you to verify a message
was received afterwards using thehave_received
matcher.
Note that you must first stub the method or use a null double.
(Joe Ferris and Joël Quenneville) - Make
at_least
andat_most
style receive expectations print that they were
expecting at least or at most some number of calls, rather than just the
number of calls given in the expectation (Sam Phippen) - Make
with
style receive expectations print the args they were expecting, and
the args that they got (Sam Phippen) - Fix some warnings seen under ruby 2.0.0p0 (Sam Phippen).
- Add a new
:expect
syntax for message expectations
(Myron Marston and Sam Phippen).
Bug fixes
- Fix
any_instance
so that a frozen object can bedup
'd when methods
have been stubbed on that type usingany_instance
(Jon Rowe). - Fix
and_call_original
so that it properly raises anArgumentError
when the wrong number of args are passed (Jon Rowe). - Fix
double
on 1.9.2 so you can wrap them in an Array
usingArray(my_double)
(Jon Rowe). - Fix
stub_const
andhide_const
to handle constants that redefinesend
(Sam Phippen). - Fix
Marshal.dump
extension so that it correctly handles nil.
(Luke Imhoff, Jon Rowe) - Fix isolation of
allow_message_expectations_on_nil
(Jon Rowe) - Use inspect to format actual arguments on expectations in failure messages (#280, Ben Langfeld)
- Protect against improperly initialised test doubles (#293) (Joseph Shraibman and Jon Rowe)
Deprecations
- Deprecate
stub
andmock
as aliases fordouble
.double
is the
best term for creating a test double, and it reduces confusion to
have only one term (Michi Huber). - Deprecate
stub!
andunstub!
in favor ofstub
andunstub
(Jon Rowe). - Deprecate
at_least(0).times
andany_number_of_times
(Michi Huber).