module RSpec::Mocks
def self.allow_message(subject, message, opts={}, &block)
- Example: Defines the implementation of `foo` on `bar`, using the passed block -
Other tags:
- Yield: - an optional implementation for the allowance
Parameters:
-
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 self.allow_message(subject, message, opts={}, &block) space.proxy_for(subject).add_stub(message, opts, &block) end
def self.configuration
Mocks specific configuration, as distinct from `RSpec.configuration`
def self.configuration @configuration ||= Configuration.new end
def self.error_generator
- Private: -
def self.error_generator @error_generator ||= ErrorGenerator.new end
def self.expect_message(subject, message, opts={}, &block)
- Example: Expect the message `foo` to receive `bar`, then call it -
Other tags:
- Yield: - an optional implementation for the expectation
Parameters:
-
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 self.expect_message(subject, message, opts={}, &block) space.proxy_for(subject).add_message_expectation(message, opts, &block) end
def self.setup
Performs per-test/example setup. This should be called before
def self.setup @space_stack << (@space = space.new_scope) end
def self.teardown
redefined on partial doubles). This _must_ be called after
Cleans up all test double state (including any methods that were
def self.teardown space.reset_all @space_stack.pop @space = @space_stack.last || @root_space end
def self.verify
Verifies any message expectations that were set during the
def self.verify space.verify_all end
def self.with_temporary_scope
Call the passed block and verify mocks after it has executed. This allows
def self.with_temporary_scope setup begin yield verify ensure teardown end end