class RSpec::Mocks::ArgumentListMatcher

@see ArgumentMatchers
arg_list_matcher.args_match?(123, :a => ‘b’)
arg_list_matcher = RSpec::Mocks::ArgumentListMatcher.new(123, hash_including(:a => ‘b’))
include RSpec::Mocks::ArgumentMatchers
require ‘rspec/mocks/argument_list_matcher’
matching without using the rest of rspec-mocks.
enables 3rd party mocking libs to take advantage of rspec’s argument
Can also be used directly to match the contents of any ‘Array`. This
object.should_receive(:message).with(hash_including(:a => ’b’))
match against the real objects .e.g.
Values passed to ‘with` can be literal values or argument matchers that
object.message(:a, ’b’, 3)
object.should_receive(:message).with(:a, ‘b’, 3)
the ‘with` method on a `MessageExpectation`:
Wrapper for matching arguments against a list of expected values. Used by

def args_match?(*args)

Other tags:
    See: #initialize -

Parameters:
  • *args (Array) --

Other tags:
    Api: - public
def args_match?(*args)
  match_any_args? || block_passes?(*args) || matchers_match?(*args)
end

def block_passes?(*args)

def block_passes?(*args)
  @block.call(*args) if @block
end

def initialize(*expected_args, &block)

Other tags:
    See: #args_match? -
    See: ArgumentMatchers -

Parameters:
  • block (Block) -- a block with arity matching the expected
  • *expected_args (Array) -- a list of expected literals and/or argument matchers

Other tags:
    Api: - public
def initialize(*expected_args, &block)
  @expected_args = expected_args
  @block = expected_args.empty? ? block : nil
  @match_any_args = false
  @matchers = nil
  case expected_args.first
  when ArgumentMatchers::AnyArgsMatcher
    @match_any_args = true
  when ArgumentMatchers::NoArgsMatcher
    @matchers = []
  else
    @matchers = expected_args.collect {|arg| matcher_for(arg)}
  end
end

def is_matcher?(object)

def is_matcher?(object)
  return false if object.respond_to?(:i_respond_to_everything_so_im_not_really_a_matcher)
  [:failure_message_for_should, :failure_message].any? do |msg|
    object.respond_to?(msg)
  end && object.respond_to?(:matches?)
end

def match_any_args?

def match_any_args?
  @match_any_args
end

def matcher_for(arg)

def matcher_for(arg)
  return ArgumentMatchers::MatcherMatcher.new(arg) if is_matcher?(arg)
  return ArgumentMatchers::RegexpMatcher.new(arg)  if arg.is_a?(Regexp)
  return ArgumentMatchers::EqualityProxy.new(arg)
end

def matchers_match?(*args)

def matchers_match?(*args)
  @matchers == args
end