rspec-mocks/Changelog.md
Breaking Changes:
should_receive/stub syntax. (Phil Pirozhkov, rspec/rspec-mocks#1365)RSpec::Mocks::CannotSupportArgMutationsError.
(Phil Pirozhkov, rspec/rspec-mocks#1400)RSpec::Mocks::Configuration#verify_partial_doubles
to true. (Phil Pirozhkov, rspec/rspec-mocks#1409)allow_message_expectations_on_nil example method.
(Phil Pirozhkov, rspec/rspec-mocks#1410)Note, 4.0.0.beta1 was released at the time of 3.13.7, and will contain contain bugfixes after that point.
Bug Fixes:
any_instance warning about prepended methods to private/protected methods. (Alex Dean, #297)Bug Fixes:
to_h, to_hash responses on null objects, prevents an issue with Rails. (Jon Rowe, rspec/rspec#275)Bug Fixes:
is_a?. (Erin Paget, rspec/rspec#265)Bug Fixes:
Bug Fixes:
Bug Fixes:
expect_any_instance_of or allow_any_instance_of
ensure the stubbed method has the same visibility as the real method.
(Jon Rowe, rspec/rspec-mocks#1596)Bug Fixes:
and_invoke. (Jon Rowe, rspec/rspec-mocks#1595)Bug Fixes:
RSpec::Support::Mutex in RSpec::Mocks::Proxy to avoid issues from
stubbing ::Mutex#new. (Eric Mueller, rspec/rspec-mocks#1575)Enhancements:
array_excluding matcher for arguments. (Zane Wolfgang Pickett, rspec/rspec-mocks#1528)Bug Fixes:
Bug Fixes:
and_call_original when using the method_missing fallback
with keyword arguments. (Igor Drozdov, rspec/rspec-mocks#1552)Bug Fixes:
with
when using any instance. (Lachlan Sylvester, rspec/rspec-mocks#1540)Bug Fixes:
with.
(Jean Boussier, rspec/rspec-mocks#1531, rspec/rspec-mocks#1534)Bug Fixes:
send for verifying doubles on Ruby 3.
(Charlie Honig, rspec/rspec-mocks#1485)Bug Fixes:
with on Ruby 3.2.0.
(Slava Kardakov, Benoit Tigeot, Phil Pirozhkov, Benoit Daloze, rspec/rspec-mocks#1514)Bug Fixes:
== (Jon Rowe, rspec/rspec-mocks#1506)frozen? due to some objects mis-behaving.
(Keegan Roth, rspec/rspec-mocks#1401)expect_any_instance_of across a class
inheritance boundary from raising rather than failing. (Jon Rowe, rspec/rspec-mocks#1496)allow(...).not_to with
unsupported matchers. (Phil Pirozhkov, rspec/rspec-mocks#1503)Enhancements:
Bug Fixes:
Class.new to detect overridden definitions
of new rather than the owner, fixing detection of "double aliased" methods
in Ruby 3 and above. (Benoit Daloze, rspec/rspec-mocks#1470, rspec/rspec-mocks#1476)with on Ruby 3.0+ with instance_double (Andrii Malyshko, rspec/rspec-mocks#1473)Bug Fixes:
ruby2_keywords calls to properly designate methods using
*args to pass keyword around, fixes an issue with TruffleRuby.
(Benoit Daloze, rspec/rspec-mocks#1464)Enhancements:
and_invoke implementation for configuring responses to receive
(and receive_messages) with multiple callable objects. (Kyle Smith, rspec/rspec-mocks#1411)Bug Fixes:
$VERBOSE to nil. (Nobuyoshi Nakada, rspec/rspec-mocks#1414)with on Ruby 3.0+ (Yusuke Endoh, rspec/rspec-mocks#1394)Bug Fixes:
and_call_original on Ruby 3.0.
(Bryan Powell, rspec/rspec-mocks#1385)RSpec::Mocks::Constant#previously_defined? is now always a boolean.
(Phil Pirozhkov, rspec/rspec-mocks#1397)expect_any_instance_of
or allow_any_instance_of with and_call_original.
(Jess Hottenstein, rspec/rspec-mocks#1407)Bug Fixes:
ArgumentError rather than TypeError when unsupported methods on
unsupported objects are attempted to be stubbed. (@zhisme, rspec/rspec-mocks#1357)Enhancements:
MessageExpectation.
This will allow rspec-expectations to inject a custom failure message.
(Benoit Tigeot and Nicolas Zermati, rspec/rspec-mocks#1312)RSpec::Mocks.with_temporary_scope
when block run. (@expeehaa, rspec/rspec-mocks#1329)Bug Fixes:
RSpec::Mocks.configuration.verifying_double_callbacks when using
allow_any_instance_of or expect_any_instance_of (Daniel Orner, rspec/rspec-mocks#1309)Enhancements:
time as an alias for times. For example:
expect(Class).to receive(:method).exactly(1).time.
(Pistos, Benoit Tigeot, rspec/rspec-mocks#1271)array_including argument matchers to be nested.
(Emmanuel Delmas, rspec/rspec-mocks#1291)Bug Fixes:
Bug Fixes:
allow_any_instance_of and expect_any_instance_of can be temporarily
supressed. (Jon Rowe, rspec/rspec-mocks#1228)expect_any_instance_of(double).to_not have_received(:some_method)
fails gracefully (as its not supported) rather than issuing a NoMethodError.
(Maxim Krizhanovsky, rspec/rspec-mocks#1231)Enhancements:
--enable-frozen-string-literal option
on Ruby 2.3+. (Pat Allan, rspec/rspec-mocks#1165)Bug Fixes:
hash_including and hash_excluding so that they work against
subclasses of Hash. (Aaron Rosenberg, rspec/rspec-mocks#1167)Bug Fixes:
Enhancements:
without_partial_double_verification { } API that lets you
temporarily turn off partial double verification for an example.
(Jon Rowe, rspec/rspec-mocks#1104)Bug Fixes:
#freeze (Alessandro Berardi, rspec/rspec-mocks#1109)new to work when <Class>.method has
been redefined. (Proby, rspec/rspec-mocks#1119)Enhancements:
RSpec::Mocks::MessageExpectation (Myron Marston, rspec/rspec-mocks#1095)Enhancements:
and_throw to any instance handling. (Tobias Bühlmann, rspec/rspec-mocks#1068)Enhancements:
allow(...).to receive(...).ordered. (Jon Rowe, rspec/rspec-mocks#1000)rspec/mocks/minitest_integration, to properly integrate rspec-mocks
with minitest. (Myron Marston, rspec/rspec-mocks#1065)Enhancements:
and_wrap_original on pure test
doubles. (betesh, rspec/rspec-mocks#1063)Bug Fixes:
receive_message_chain(...).with(...) working
correctly on "any instance" mocks. (Jon Rowe, rspec/rspec-mocks#1061)Bug Fixes:
any_instance_of(...).to receive(...) to use and_yield multiple
times. (Kilian Cirera Sant, rspec/rspec-mocks#1054)rspec-mocks matchers to be used for
allow. (Andrew Kozin, rspec/rspec-mocks#1056)respond_to? on partial doubles from causing infinite
recursion. (Jon Rowe, rspec/rspec-mocks#1013)any_instance (regression from rspec/rspec-mocks#1043). (Joe Rafaniello, rspec/rspec-mocks#1060)Bug Fixes:
any_instance to work properly on Ruby 2.3. (Joe Rafaniello, rspec/rspec-mocks#1043)Enhancements:
expect(...).to have_received work without relying upon
rspec-expectations. (Myron Marston, rspec/rspec-mocks#978)nil.
(Liz Rush, rspec/rspec-mocks#983)Bug Fixes:
have_received { ... } so that any block passed when the message
was received is forwarded to the have_received block. (Myron Marston, rspec/rspec-mocks#1006)respond_to?.
(Alex Dowad, rspec/rspec-mocks#1022)receive on subclasses (at a class level) with 1.8.7.
(Alex Dowad, rspec/rspec-mocks#1026)Bug Fixes:
before_verifying_doubles callbacks). (Jon Rowe, rspec/rspec-mocks#980, rspec/rspec-mocks#979)Bug Fixes:
before_verifying_double callback logic that caused it to be called
once for each class in the ancestor list when mocking or stubbing a class. Now
it is only called for the mocked or stubbed class, as you would expect. (Sam
Phippen, rspec/rspec-mocks#974)Enhancements:
new on MyClass or class_double(MyClass), use the
method signature from MyClass#initialize to verify arguments.
(Myron Marston, rspec/rspec-mocks#886)stringio unnecessarily. (Myron Marston, rspec/rspec-mocks#894)RSpec::Mocks::Configuration#when_declaring_verifying_double to
RSpec::Mocks::Configuration#before_verifying_doubles and utilise when
verifying partial doubles. (Jon Rowe, rspec/rspec-mocks#940)ObjectFormatter for improved formatting of
arguments in failure messages so that, for example, full time
precisions is displayed for time objects. (Gavin Miller, Myron Marston, rspec/rspec-mocks#955)Bug Fixes:
have_received(msg).with(args).exactly(n).times and
receive(msg).with(args).exactly(n).times failure messages
for when the message was received the wrong number of times with
the specified args, and also received additional times with other
arguments. Previously it confusingly listed the arguments as being
mis-matched (even when the double was allowed to receive with any
args) rather than listing the count. (John Ceh, rspec/rspec-mocks#918)any_args/anything support so that we avoid calling obj == anything
on user objects that may have improperly implemented == in a way that
raises errors. (Myron Marston, rspec/rspec-mocks#924)NoMethodError internally in RSpec. (Myron Marston rspec/rspec-mocks#954)Bug Fixes:
rspec/support/differ require so that rspec-mocks can be
used w/o rspec-expectations (which also loads the differ and hided the
fact we forgot to require it). (Myron Marston, rspec/rspec-mocks#893)Enhancements:
any_args as an arg splat, allowing it to match an arbitrary
number of args at any point in an arg list. (Myron Marston, rspec/rspec-mocks#786)instance_double, instance_spy,
class_double, class_spy, object_double, object_spy). (Cezary
Baginski, rspec/rspec-mocks#826)array_including and hash_including argument matchers composable.
(Sam Phippen, rspec/rspec-mocks#819)allow_any_instance_of(...).to receive(...).and_wrap_original
work. (Ryan Fitzgerald, rspec/rspec-mocks#869)Bug Fixes:
no_args with
additional arguments (e.g. expect().to receive().with(no_args, 1)).
(Myron Marston, rspec/rspec-mocks#786)any_args multiple times in the
same argument list (e.g. expect().to receive().with(any_args, 1, any_args).
(Myron Marston, rspec/rspec-mocks#786)(instance|class)_double(SomeConst)
work properly when SomeConst has previously been stubbed.
(instance|class)_double("SomeClass") already worked properly.
(Myron Marston, rspec/rspec-mocks#824)receive, receive_messages and
receive_message_chain. (Myron Marston, rspec/rspec-mocks#828)RSpec::Mocks::Constant.original when called with an invalid
constant to return an object indicating the constant name is invalid,
rather than blowing up. (Myron Marston, rspec/rspec-mocks#833)extend RSpec::Mocks::ExampleMethods on any object work properly
to add the rspec-mocks API to that object. Previously, expect would
be undefined. (Myron Marston, rspec/rspec-mocks#846)require 'rspec/mocks/standalone' so that it only affects main
and not every object. It's really only intended to be used in a REPL
like IRB, but some gems have loaded it, thinking it needs to be loaded
when using rspec-mocks outside the context of rspec-core.
(Myron Marston, rspec/rspec-mocks#846)with) after they have been invoked. (Sam Phippen and Melanie Gilman, rspec/rspec-mocks#837)file.reopen(io) after previously
stubbing a method on the file object. (Myron Marston, rspec/rspec-mocks#853)have_received(...).with(...) expectation. (Myron Marston, rspec/rspec-mocks#868)Bug Fixes:
have_received matcher.
(Jon Rowe, rspec/rspec-mocks#793)allow_any_instance_of(...) or
expect_any_instance_of(...) with the have_received matcher (they are
not intended to be used together and previously caused an odd internal
failure in rspec-mocks). (Jon Rowe, rspec/rspec-mocks#799).with verification so that it applies to method
stubs. (Myron Marston, rspec/rspec-mocks#790)Bug Fixes:
allow(...) with the
have_received matcher (they are not intended to be used together
and previously caused an odd internal failure in rspec-mocks). (Jon Rowe, rspec/rspec-mocks#788).Bug Fixes:
any_instance_of(...). (Tony Novak, rspec/rspec-mocks#781)Enhancements:
spy, ìnstance_spy, class_spy and object_spy)
which create doubles as null objects for use with spying in testing. (Sam
Phippen, rspec/rspec-mocks#671)have_received matcher will raise "does not implement" errors correctly when
used with verifying doubles and partial doubles. (Xavier Shay, rspec/rspec-mocks#722)with
expectations. (Xavier Shay, rspec/rspec-mocks#726)thrice modifier to message expectation interface as a synonym
for exactly(3).times. (Dennis Taylor, rspec/rspec-mocks#753)thrice synonyms e.g. .at_least(:thrice), .at_most(:thrice),
receive(...).thrice and have_received(...).thrice. (Jon Rowe, rspec/rspec-mocks#754)and_wrap_original modifier for partial doubles to mutate the
response from a method. (Jon Rowe, rspec/rspec-mocks#762)Bug Fixes:
any_number_of_times from any_instance recorders that were
erroneously causing mention of the method in documentation. (Jon Rowe, rspec/rspec-mocks#760)Bug Fixes:
kind_of(x) to match using arg.kind_of?(x) (like RSpec 2)
rather than x === arg. (Jon Rowe, rspec/rspec-mocks#750)Bug Fixes:
have_received matcher will raise "does not implement" errors correctly when
used with verifying doubles and partial doubles. (Xavier Shay, rspec/rspec-mocks#722)double.as_null_object.dup and double.as_null_object.clone
make the copies be null objects. (Myron Marston, rspec/rspec-mocks#732)BasicObject in 1.8.7. (Chris Griego, rspec/rspec-mocks#739)Bug Fixes:
ordered work with exact receive counts. (Sam Phippen, rspec/rspec-mocks#713)Bug Fixes:
receive_message_chain(...) so that it supports with just like
stub_chain did. (Jon Rowe, rspec/rspec-mocks#697)expect_any_instance_of so that it expects the
message on any instance rather than on every instance.
(Myron Marston, rspec/rspec-mocks#699)Bug Fixes:
transfer_nested_constants option so that transferred constants
get properly reset at the end of the example. (Myron Marston)config.transfer_nested_constants = true so that you don't
erroneously get errors when stubbing a constant that is not a module
or a class. (Myron Marston)double(:class => SomeClass) to later
trigger infinite recursion. (Myron Marston)have_received(...).with(...).ordered where it was not
taking the args into account when checking the order. (Myron Marston)have_received(...).ordered where it was wrongly
considering stubs when checking the order. (Myron Marston)TypeError during instance method
staging on 2.0.0-p195, suffers from https://bugs.ruby-lang.org/issues/8686
too. (Cezar Halmagean).Breaking Changes for 3.0.0:
RSpec::Mocks::TestDouble.extend_onto. (Myron Marston)RSpec::Mocks::ConstantStubber. (Jon Rowe)Enhancements:
anything, duck_type and instance_of argument
matchers. (Jon Rowe)Bug Fixes:
double.as_null_object.to_str to return the double rather
than a string. (Myron Marston)expect(dbl).to receive_message_chain(:foo, :bar) where it was
not setting an expectation for the last message in the chain.
(Jonathan del Strother)StackLevelTooDeep errors when stubbing an any_instance method that's
accessed in inspect by providing our own inspect output. (Jon Rowe)any_instance logic that did not allow you to mock or stub
private methods if verify_partial_doubles was configured. (Oren Dobzinski)and_call_original to work properly when multiple classes in an
inheritance hierarchy have been stubbed with the same method. (Myron Marston)any_instance so that it updates existing instances that have
already been stubbed. (Myron Marston)expect_any_instance_of so that when the message is received
on an individual instance that has been directly stubbed, it still
satisfies the expectation. (Sam Phippen, Myron Marston)any_instance to mock or stub a method
that is defined on a module prepended onto the class. This triggered
SystemStackError before and is very hard to support so we are not
supporting it at this time. (Myron Marston)Breaking Changes for 3.0.0:
RSpec::Mocks::Mock to RSpec::Mocks::Double. (Myron Marston)RSpec::Mocks::ExampleMethods in your test context.
(Myron Marston)before(:all) hook). (Sam Phippen)host argument of RSpec::Mocks.setup. Instead
RSpec::Mocks::ExampleMethods should be included directly in the scope where
RSpec's mocking capabilities are used. (Sam Phippen)and_return { value } and and_return without arguments. (Yuji Nakayama)Enhancements:
receive_message_chain which provides the functionality of the old
stub_chain for the new allow/expect syntax. Use it like so: allow(...).to receive_message_chain(:foo, :bar, :bazz). (Sam Phippen).=== as their primary matching
protocol, since their semantics mirror that of a case or rescue statement
(which uses === for matching). (Myron Marston)RSpec::Mocks.with_temporary_scope, which allows you to create
temporary rspec-mocks scopes in arbitrary places (such as a
before(:all) hook). (Myron Marston)Bug Fixes:
double("string_name" => :value)
to stop working. (Xavier Shay)let with the same name as one of the methods
from RSpec::Mocks::ArgumentMatchers, the user's let takes
precedence. (Michi Huber, Myron Marston):should syntax w/o explicit
config so that it no longer is silenced by an extension gem such
as rspec-rails when it calls config.add_stub_and_should_receive_to.
(Sam Phippen)expect syntax so that it does not wrongly emit a "You're
overriding a previous implementation for this stub" warning when
you are not actually doing that. (Myron Marston)any_instance.unstub when used on sub classes for whom the super
class has had any_instance.stub invoked on. (Jon Rowe)stub_chain/receive_message_chain that caused
it to raise an ArgumentError when passing args to the stubbed
methods. (Sam Phippen)VerifyingDoubleNotDefinedError when a constant is not defined for
a verifying class double. (Maurício Linhares)Double#to_str, which caused confusing raise some_double
behavior. (Maurício Linhares)Breaking Changes for 3.0.0:
should_not_receive(...).and_return is used. (Sam
Phippen)stub! and unstub!. (Sam Phippen)mock(name, methods) and stub(name, methods), leaving
double(name, methods) for creating test doubles. (Sam Phippen, Michi Huber)any_number_of_times since should_receive(:msg).any_number_of_times
is really a stub in a mock's clothing. (Sam Phippen)at_least(0) raise an error. (Sam Phippen)require 'spec/mocks' which had been kept
in place for backwards compatibility with RSpec 1. (Myron Marston)with are always used as implementation. (Xavier Shay)any_instance implementation blocks now defaults to "on". (Sam Phippen)Enhancements:
have_received matcher to use a block to set further expectations
on arguments. (Tim Cowlishaw)instance_double and class_double to create verifying doubles,
ported from rspec-fire. (Xavier Shay)as_null_object on a verifying double only responds to defined methods.
(Xavier Shay)object_double to create verified doubles of specific object
instances. (Xavier Shay)verify_partial_doubles configuration that provides object_double
like verification behaviour on partial doubles. (Xavier Shay)transfer_nested_constants option for constant stubbing can
be configured. (Xavier Shay)receive_messages(:message => :value). (Jon Rowe)allow(Klass.any_instance) and expect(Klass.any_instance) now print a
warning. This is usually a mistake, and users usually want
allow_any_instance_of or expect_any_instance_of instead. (Sam Phippen)instance_double and class_double raise ArgumentError if the underlying
module is loaded and the arity of the method being invoked does not match the
arity of the method as it is actually implemented. (Andy Lindeman)Deprecations:
:should syntax without explicitly configuring it
is deprecated. It will continue to work but will emit a deprecation
warning in RSpec 3 if you do not explicitly enable it. (Sam Phippen)Bug Fixes:
and_call_original to handle a complex edge case involving
singleton class ancestors. (Marc-André Lafortune, Myron Marston)#inspect rather than #description if #description
returns nil or '' so that you still get a useful message.
(Nick DeLuca)Bug Fixes:
with with no arguments e.g. with(). (Yousuke, rspec/rspec-mocks#970)Bug Fixes:
Enhancements:
#=== matching and DateTime#=== behaviour.
(Jon Rowe, rspec/rspec-mocks#735)Bug Fixes:
double.as_null_object had been frozen. (Yuji Nakayama, rspec/rspec-mocks#698)Deprecations:
No changes. Just taking it out of pre-release.
Deprecations:
RSpec::Mocks::TestDouble.extend_onto. (Myron Marston)RSpec::Mocks::ConstantStubber. (Jon Rowe)Marshal.dump monkey-patch without opt-in. (Xavier Shay)Deprecations:
RSpec::Mocks::Mock in favor of RSpec::Mocks::Double.
(Myron Marston)host argument of RSpec::Mocks.setup. Instead
RSpec::Mocks::ExampleMethods should be included directly in the scope where
RSpec's mocking capabilities are used. (Sam Phippen)before(:all) hook). (Myron Marston)and_return { value } and and_return without arguments. (Yuji Nakayama)Deprecations
as_null_object
state was not reset and some users relied on this to have a null object
double that is used for many examples. This behavior will be removed in 3.0.
(Myron Marston)any_instance implementation block is used
when the new yield_receiver_to_any_instance_implementation_blocks config
option is not explicitly set, as RSpec 3.0 will default to enabling this new
feature. (Sam Phippen)Enhancements:
any_instance implementation
blocks. (Sam Phippen)Bug Fixes:
any_instance method stubs and expectations are torn down regardless of
expectation failures. (Sam Phippen)Bug Fixes:
1 no matter how many args the block receives if it
receives a block, too. (Myron Marston)Bug Fixes:
and_return etc) (Jon Rowe)Bug Fixes:
Bug Fixes:
as_null_object doubles so that they return nil from to_ary
(Jon Rowe).stub! (with an implicit receiver)
return a test double rather than stub a method (Myron Marston).Bug Fixes:
double.as_null_object behavior from 2.13 and earlier: a
double's nullness persisted between examples in earlier examples.
While this is not an intended use case (test doubles are meant to live
for only one example), we don't want to break behavior users rely
on in a minor relase. This will be deprecated in 2.99 and removed
in 3.0. (Myron Marston)Enhancements:
array_including matcher. (Sam Phippen)Bug Fixes:
double so that it sets up passed stubs correctly regardless of
the configured syntax (Paul Annesley).and_yield, and_raise, and_return or and_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 using spork or
similar preloading gems (Andy Lindeman).Enhancements:
any_instance dup'ing and YAML 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).have_received matcher.
Note that you must first stub the method or use a null double.
(Joe Ferris and Joël Quenneville)at_least and at_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)with style receive expectations print the args they were expecting, and
the args that they got (Sam Phippen):expect syntax for message expectations
(Myron Marston and Sam Phippen).Bug fixes
any_instance so that a frozen object can be dup'd when methods
have been stubbed on that type using any_instance (Jon Rowe).and_call_original so that it properly raises an ArgumentError
when the wrong number of args are passed (Jon Rowe).double on 1.9.2 so you can wrap them in an Array
using Array(my_double) (Jon Rowe).stub_const and hide_const to handle constants that redefine send
(Sam Phippen).Marshal.dump extension so that it correctly handles nil.
(Luke Imhoff, Jon Rowe)allow_message_expectations_on_nil (Jon Rowe)Deprecations
stub and mock as aliases for double. double is the
best term for creating a test double, and it reduces confusion to
have only one term (Michi Huber).stub! and unstub! in favor of stub and unstub
(Jon Rowe).at_least(0).times and any_number_of_times (Michi Huber).Bug fixes
and_yield, and_raise, and_return or and_throw (Myron Marston).Bug fixes
obj.stub(:foo).and_return(1, 2)) was later mocked with a
single return value (e.g. obj.should_receive(:foo).once.and_return(1)).
(Myron Marston)with constraints. Previously, the
first stub was used, even though it may not have matched the passed
args. The fix defers this decision until the message is received so
that the proper stub response can be chosen based on the passed
arguments (Myron Marston).nil? extra times on a mocked object, in case nil?
itself is expected a set number of times (Myron Marston).missing_default_stub_error message so array args are handled
properly (Myron Marston).any_instance.unstub! (Ryan Jones).any_instance stubbing so that it works with Delegator
subclasses (Myron Marston).and_call_original so that it works with Delegator subclasses
(Myron Marston).any_instance.should_not_receive when any_instance.should_receive
is used on the same class in the same example. Previously it would
wrongly report a failure even when the message was not received
(Myron Marston).Bug fixes
and_call_original to work properly for methods defined
on a module extended onto an object instance (Myron Marston).stub_const with an undefined constnat name to work properly
with constant strings that are prefixed with :: -- and edge case
I missed in the bug fix in the 2.12.1 release (Myron Marston).extend self)
when the method visibility differs between the instance and singleton
versions (Andy Lindeman).Bug fixes
any_instance to support and_call_original.
(Myron Marston)hide_const and stub_const with a defined constnat name to
work properly with constant strings that are prefixed with :: (Myron Marston).Enhancements
and_raise can accept an exception class and message, more closely
matching Kernel#raise (e.g., foo.stub(:bar).and_raise(RuntimeError, "message"))
(Bas Vodde)and_call_original, which will delegate the message to the
original method (Myron Marston).Deprecations:
and_return with should_not_receive
(Neha Kumari)Bug fixes
:transfer_nested_constants option of stub_const so that it
doesn't blow up when there are inherited constants. (Myron Marston)any_instance stubs can be used on classes that override Object#method.
(Andy Lindeman)any_instance are unstubbed after the test finishes.
(Andy Lindeman)Bug fixes
dup on classes that don't support dup (David Chelimsky)any_instance so that it works properly with methods defined on
a superclass. (Daniel Eguzkiza)stub_const so that it works properly for nested constants that
share a name with a top-level constant (e.g. "MyGem::Hash"). (Myron
Marston)Bug fixes
should_receive so that when it is called on an as_null_object
double with no implementation, and there is a previous explicit stub
for the same method, the explicit stub remains (rather than being
overridden with the null object implementation--return self). (Myron
Marston)Enhancements
stub_const API to stub constants for the duration of an
example (Myron Marston).Bug fixes
double.should_receive(:foo) { a }
was causing a NoMethodError when double.stub(:foo).and_return(a, b)
had been setup before (Myron Marston).any_instance and dup. (Sidu Ponnappa @kaiwren)double.should_receive(:foo).at_least(:once).and_return(a) always returns a
even if :foo is already stubbed."%i" % double.as_null_object). (Myron Marston)should_receive so that null object behavior (e.g. returning
self) is preserved if no implementation is given (Myron Marston).and_raise so that it raises RuntimeError rather than
Exception by default, just like ruby does. (Andrew Marshall)Bug fixes
object.should_receive(:message).at_least(0).times.and_return valueobject.should_not_receive(:message).and_return valueBug fixes
exactly or at_most expectation is exceededEnhancements
Bug fixes
as_null_object to be passed to withNo changes for this release. Just releasing with the other rspec gems.
No changes for this release. Just releasing with the other rspec gems.
Enhancements
Enhancements
__send__ rather than send (alextk)any_instance.stub_chain (Sidu Ponnappa)any_instance argument matching based on with (Sidu
Ponnappa and Andy Lindeman)Changes
failure_message_for_should or failure_message instead of
description to detect a matcher (Tibor Claassen)Bug fixes
any_instance.stub. (Justin Ko)to_ary to be called without raising NoMethodError (Mikhail
Dieterle)any_instance properly restores private methods (Sidu Ponnappa)Enhancements
any_instance.stub and any_instance.should_receive (Sidu
Ponnappa and Andy Lindeman)Bug fixes
Bug fixes
No functional changes in this release, which was made to align with the rspec-core-2.4.0 release.
Bug fixes
@mock_proxy instance variable. (Myron Marston)Enhancements
Bug fix
obj.should_receive(:foo).with(stub.as_null_object) would pass
with a false positive.Bug fixes
Enhancements
obj.should_receive(:msg) {|&block| ... }Bug fixes
Bug fixes
obj.stub_chain(:a, :b => :c)obj.stub_chain(:a, :b) { :c }respond_to? always returns true when using as_null_object