Module RSpec::Mocks::ArgumentMatchers
In: lib/rspec/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

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::HashIncludingMatcher
Class RSpec::Mocks::ArgumentMatchers::HashNotIncludingMatcher
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

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

Passes as long as there is an argument.

Passes if the argument responds to the specified messages.

Examples

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

: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.

Passes if arg.instance_of?(klass)

Passes if arg.kind_of?(klass)

Passes if no arguments are passed along with the message

[Validate]