RSpec's 'test double' framework, with support for stubbing and mocking
MIT License
Bot releases are hidden (Show)
Bug Fixes:
any_instance
method stubs and expectations are torn down regardless ofPublished by myronmarston over 10 years ago
Deprecations:
RSpec::Mocks::Mock
in favor of RSpec::Mocks::Double
.host
argument of RSpec::Mocks.setup
. InsteadRSpec::Mocks::ExampleMethods
should be included directly in the scope wherebefore(:all)
hook). (Myron Marston)and_return { value }
and and_return
without arguments. (Yuji Nakayama)Published by myronmarston over 10 years ago
Breaking Changes for 3.0.0:
RSpec::Mocks::Mock
to RSpec::Mocks::Double
. (Myron Marston)RSpec::Mocks::ExampleMethods
in your test context.before(:all)
hook). (Sam Phippen)host
argument of RSpec::Mocks.setup
. InsteadRSpec::Mocks::ExampleMethods
should be included directly in the scope whereand_return { value }
and and_return
without arguments. (Yuji Nakayama)Enhancements:
receive_message_chain
which provides the functionality of the oldstub_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===
for matching). (Myron Marston)RSpec::Mocks.with_temporary_scope
, which allows you to createbefore(:all)
hook). (Myron Marston)Bug Fixes:
double("string_name" => :value)
let
with the same name as one of the methodsRSpec::Mocks::ArgumentMatchers
, the user's let
takes:should
syntax w/o explicitconfig.add_stub_and_should_receive_to
.expect
syntax so that it does not wrongly emit a "You'reany_instance.unstub
when used on sub classes for whom the superany_instance.stub
invoked on. (Jon Rowe)stub_chain
/receive_message_chain
that causedArgumentError
when passing args to the stubbedVerifyingDoubleNotDefinedError
when a constant is not defined forDouble#to_str
, which caused confusing raise some_double
Published by myronmarston over 10 years ago
Bug Fixes:
1
no matter how many args the block receives if itPublished by myronmarston almost 11 years ago
Breaking Changes for 3.0.0:
should_not_receive(...).and_return
is used. (Samstub!
and unstub!
. (Sam Phippen)mock(name, methods)
and stub(name, methods)
, leavingdouble(name, methods)
for creating test doubles. (Sam Phippen, Michi Huber)any_number_of_times
since should_receive(:msg).any_number_of_times
at_least(0)
raise an error. (Sam Phippen)require 'spec/mocks'
which had been keptwith
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 expectationsinstance_double
and class_double
to create verifying doubles,rspec-fire
. (Xavier Shay)as_null_object
on a verifying double only responds to defined methods.object_double
to create verified doubles of specific objectconfiguration that provides
object_double`transfer_nested_constants
option for constant stubbing canreceive_messages(:message => :value)
. (Jon Rowe)allow(Klass.any_instance)
and expect(Klass.any_instance)
now print aallow_any_instance_of
or expect_any_instance_of
instead. (Sam Phippen)instance_double
and class_double
raise ArgumentError
if the underlyingDeprecations:
:should
syntax without explicitly configuring itBug Fixes:
and_call_original
to handle a complex edge case involving#inspect
rather than #description
if #description
nil
or ''
so that you still get a useful message.Published by myronmarston almost 11 years ago
Deprecations
as_null_object
any_instance
implementation block is usedyield_receiver_to_any_instance_implementation_blocks
configEnhancements:
any_instance
implementationPublished by myronmarston about 11 years ago
Bug Fixes:
and_return
etc) (Jon Rowe)Published by myronmarston about 11 years ago
Bug Fixes:
Published by myronmarston about 11 years ago
Bug Fixes:
as_null_object
doubles so that they return nil
from to_ary
stub!
(with an implicit receiver)Bug Fixes:
double.as_null_object
behavior from 2.13 and earlier: aPublished by myronmarston over 11 years ago
Enhancements:
array_including
matcher. (Sam Phippen)Bug Fixes:
double
so that it sets up passed stubs correctly regardless ofand_yield
, and_raise
, and_return
or and_throw
. This got fixedMarshal.dump
does not unnecessarily duplicate objects when rspec-mocks hasspork
orEnhancements:
any_instance
dup'ing and YAML
serialization,__id__
have_received
matcher.at_least
and at_most
style receive expectations print that they werewith
style receive expectations print the args they were expecting, and:expect
syntax for message expectationsBug fixes
any_instance
so that a frozen object can be dup
'd when methodsany_instance
(Jon Rowe).and_call_original
so that it properly raises an ArgumentError
double
on 1.9.2 so you can wrap them in an ArrayArray(my_double)
(Jon Rowe).stub_const
and hide_const
to handle constants that redefine send
Marshal.dump
extension so that it correctly handles nil.allow_message_expectations_on_nil
(Jon Rowe)Deprecations
stub
and mock
as aliases for double
. double
is thestub!
and unstub!
in favor of stub
and unstub
at_least(0).times
and any_number_of_times
(Michi Huber).