Module: Spec::Mocks::ArgumentMatchers

Module | Spec::Mocks::ArgumentMatchers
In: | lib/spec/mocks/argument_matchers.rb

ArgumentMatchers are messages that you can include in message expectations to match arguments against a broader check than simple equality.

With the exception of any_args() and no_args(), the matchers are all positional - they match against the arg in the given position.

### Methods

a_kind_of an_instance_of any_args anything boolean duck_type hash_including hash_not_including instance_of kind_of no_args

### Classes and Modules

Class Spec::Mocks::ArgumentMatchers::AnyArgMatcher
Class Spec::Mocks::ArgumentMatchers::AnyArgsMatcher
Class Spec::Mocks::ArgumentMatchers::BooleanMatcher
Class Spec::Mocks::ArgumentMatchers::DuckTypeMatcher
Class Spec::Mocks::ArgumentMatchers::EqualityProxy
Class Spec::Mocks::ArgumentMatchers::HashIncludingMatcher
Class Spec::Mocks::ArgumentMatchers::HashNotIncludingMatcher
Class Spec::Mocks::ArgumentMatchers::InstanceOf
Class Spec::Mocks::ArgumentMatchers::KindOf
Class Spec::Mocks::ArgumentMatchers::MatcherMatcher
Class Spec::Mocks::ArgumentMatchers::NoArgsMatcher
Class Spec::Mocks::ArgumentMatchers::RegexpMatcher

### Public Instance methods

a_kind_of(klass)

Alias for kind_of

an_instance_of(klass)

Alias for instance_of

object.should_receive(:message).with(any_args())

Passes if object receives :message with any args at all. This is really a more explicit variation of object.should_receive(:message)

object.should_receive(:message).with(anything())

Passes as long as there is an argument.

object.should_receive(:message).with(boolean())

Passes if the argument is boolean.

object.should_receive(:message).with(duck_type(:hello))
object.should_receive(:message).with(duck_type(:hello, :goodbye))

Passes if the argument responds to the specified messages.

## Examples

      array = []
      display = mock('display')
      display.should_receive(:present_names).with(duck_type(:length, :each))
      => passes

hash_including(*args)

:call-seq:

      object.should_receive(:message).with(hash_including(:key => val))
      object.should_receive(:message).with(hash_including(:key))
      object.should_receive(:message).with(hash_including(:key, :key2 => val2))

Passes if the argument is a hash that includes the specified key(s) or key/value pairs. If the hash includes other keys, it will still pass.

object.should_receive(:message).with(hash_not_including(:key => val))
object.should_receive(:message).with(hash_not_including(:key))
object.should_receive(:message).with(hash_not_including(:key, :key2 => :val2))

Passes if the argument is a hash that doesn‘t include the specified key(s) or key/value

instance_of(klass)

Passes if arg.instance_of?(klass)

kind_of(klass)

Passes if arg.kind_of?(klass)

object.should_receive(:message).with(no_args)

Passes if no arguments are passed along with the message

[Validate]