def self.enable_should(syntax_host = default_should_syntax_host)
return if should_enabled?(syntax_host)
syntax_host.class_eval do
def should_receive(message, opts={}, &block)
opts[:expected_from] ||= caller(1)[0]
::RSpec::Mocks.expect_message(self, message.to_sym, opts, &block)
end
def should_not_receive(message, &block)
opts = {:expected_from => caller(1)[0]}
::RSpec::Mocks.expect_message(self, message.to_sym, opts, &block).never
end
def stub(message_or_hash, opts={}, &block)
::RSpec::Mocks::Syntax.stub_object(self, message_or_hash, opts, &block)
end
def unstub(message)
::RSpec::Mocks.space.proxy_for(self).remove_stub(message)
end
def stub!(message_or_hash, opts={}, &block)
::RSpec.deprecate "stub!", :replacement => "stub"
::RSpec::Mocks::Syntax.stub_object(self, message_or_hash, opts, &block)
end
def unstub!(message)
::RSpec.deprecate "unstub!", :replacement => "unstub"
unstub(message)
end
def stub_chain(*chain, &blk)
::RSpec::Mocks::StubChain.stub_chain_on(self, *chain, &blk)
end
def as_null_object
@_null_object = true
::RSpec::Mocks.proxy_for(self).as_null_object
end
def null_object?
defined?(@_null_object)
end
def received_message?(message, *args, &block)
::RSpec::Mocks.proxy_for(self).received_message?(message, *args, &block)
end
unless Class.respond_to? :any_instance
Class.class_eval do
def any_instance
::RSpec::Mocks.any_instance_recorder_for(self)
end
end
end
end
end