Module RSpec::Mocks::ArgumentMatchers
In: lib/rspec/mocks/argument_matchers.rb

ArgumentMatchers are placeholders 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`, they all match against the arg in same position in the argument list.

@see ArgumentListMatcher

Methods

Classes and Modules

Class RSpec::Mocks::ArgumentMatchers::AnyArgMatcher
Class RSpec::Mocks::ArgumentMatchers::AnyArgsMatcher
Class RSpec::Mocks::ArgumentMatchers::BooleanMatcher
Class RSpec::Mocks::ArgumentMatchers::DuckTypeMatcher
Class RSpec::Mocks::ArgumentMatchers::EqualityProxy
Class RSpec::Mocks::ArgumentMatchers::HashExcludingMatcher
Class RSpec::Mocks::ArgumentMatchers::HashIncludingMatcher
Class RSpec::Mocks::ArgumentMatchers::InstanceOf
Class RSpec::Mocks::ArgumentMatchers::KindOf
Class RSpec::Mocks::ArgumentMatchers::MatcherMatcher
Class RSpec::Mocks::ArgumentMatchers::NoArgsMatcher
Class RSpec::Mocks::ArgumentMatchers::RegexpMatcher

Public Instance methods

a_kind_of(klass)

Alias for kind_of

an_instance_of(klass)

Alias for instance_of

Matches any args at all. Supports a more explicit variation of `object.should_receive(:message)`

@example

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

Matches any argument at all.

@example

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

Matches a boolean value.

@example

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

Matches if the actual argument responds to the specified messages.

@example

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

Matches a hash that doesn‘t include the specified key(s) or key/value.

@example

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

Matches a hash that includes the specified key(s) or key/value pairs. Ignores any additional keys.

@example

  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))
hash_not_including(*args)

Alias for hash_excluding

Matches if `arg.instance_of?(klass)`

@example

  object.should_receive(:message).with(instance_of(Thing))

Matches if `arg.kind_of?(klass)` @example

  object.should_receive(:message).with(kind_of(Thing))

Matches no arguments.

@example

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

[Validate]