module RSpec::Mocks
def self.configuration
def self.configuration @configuration ||= Configuration.new end
def self.const_missing(name)
def self.const_missing(name) if const = DEPRECATED_CONSTANTS[name] RSpec.deprecate("RSpec::Mocks::#{name}", :replacement => const.name) const else super end end
def allow_message(subject, message, opts={}, &block)
- Example: Defines the implementation of `foo` on `bar`, using the passed block -
Parameters:
-
block
() -- an optional implementation for the allowance
-
opts
() -- a hash of options, :expected_from is used to set the
-
message
() -- a symbol, representing the message that will be
-
subject
() -- the subject to which the message will be added
def allow_message(subject, message, opts={}, &block) orig_caller = opts.fetch(:expected_from) { CallerFilter.first_non_rspec_line } ::RSpec::Mocks.proxy_for(subject). add_stub(orig_caller, message.to_sym, opts, &block) end
def any_instance_recorder_for(klass)
def any_instance_recorder_for(klass) space.any_instance_recorder_for(klass) end
def expect_message(subject, message, opts={}, &block)
- Example: Expect the message `foo` to receive `bar`, then call it -
Parameters:
-
block
() -- an optional implementation for the expectation
-
opts
() -- a hash of options, :expected_from is used to set the
-
message
() -- a symbol, representing the message that will be
-
subject
() -- the subject on which the message will be expected
def expect_message(subject, message, opts={}, &block) orig_caller = opts.fetch(:expected_from) { CallerFilter.first_non_rspec_line } ::RSpec::Mocks.proxy_for(subject). add_message_expectation(orig_caller, message.to_sym, opts, &block) end
def method_handle_for(object, method_name)
- Api: - private
def method_handle_for(object, method_name) if ::Kernel === object KERNEL_METHOD_METHOD.bind(object).call(method_name) else object.method(method_name) end end
def proxies_of(klass)
def proxies_of(klass) space.proxies_of(klass) end
def proxy_for(object)
def proxy_for(object) space.proxy_for(object) end
def setup(host=nil)
def setup(host=nil) host_is_from_rspec_core = defined?(::RSpec::Core::ExampleGroup) && host.is_a?(::RSpec::Core::ExampleGroup) if host unless host_is_from_rspec_core RSpec.deprecate( "The host argument to `RSpec::Mocks.setup`", :replacement => "`include RSpec::Mocks::ExampleMethods` in #{host.inspect}" ) end (class << host; self; end).class_eval do include RSpec::Mocks::ExampleMethods end end space.outside_example = false end
def teardown
def teardown space.reset_all space.outside_example = true end
def verify
def verify space.verify_all end