module RSpec::Mocks
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) { caller(1)[0] } ::RSpec::Mocks.proxy_for(subject). add_message_expectation(orig_caller, message.to_sym, opts, &block) end