Class RSpec::Mocks::ArgumentListMatcher
In: lib/rspec/mocks/argument_list_matcher.rb
Parent: Object

Wrapper for matching arguments against a list of expected values. Used by the `with` method on a `MessageExpectation`:

    object.should_receive(:message).with(:a, 'b', 3)
    object.message(:a, 'b', 3)

Values passed to `with` can be literal values or argument matchers that match against the real objects .e.g.

    object.should_receive(:message).with(hash_including(:a => 'b'))

Can also be used directly to match the contents of any `Array`. This enables 3rd party mocking libs to take advantage of rspec‘s argument matching without using the rest of rspec-mocks.

    require 'rspec/mocks/argument_list_matcher'
    include RSpec::Mocks::ArgumentMatchers

    arg_list_matcher = RSpec::Mocks::ArgumentListMatcher.new(123, hash_including(:a => 'b'))
    arg_list_matcher.args_match?(123, :a => 'b')

@see ArgumentMatchers

Methods

args_match?   new  

Attributes

expected_args  [R]  @private

Public Class methods

@api public @param [Array] *expected_args a list of expected literals and/or argument matchers @param [Block] block a block with arity matching the expected

Initializes an `ArgumentListMatcher` with a collection of literal values and/or argument matchers, or a block that handles the evaluation for you.

@see ArgumentMatchers @see args_match?

Public Instance methods

@api public @param [Array] *args

Matches each element in the `expected_args` against the element in the same position of the arguments passed to `new`.

@see initialize

[Validate]