module Rspec::Mocks::ArgumentMatchers

def any_args

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

object.should_receive(:message).with(any_args())
:call-seq:
def any_args
  AnyArgsMatcher.new
end

def anything

Passes as long as there is an argument.

object.should_receive(:message).with(anything())
:call-seq:
def anything
  AnyArgMatcher.new(nil)
end

def anythingize_lonely_keys(*args)

def anythingize_lonely_keys(*args)
  hash = args.last.class == Hash ? args.delete_at(-1) : {}
  args.each { | arg | hash[arg] = anything }
  hash
end

def boolean

Passes if the argument is boolean.

object.should_receive(:message).with(boolean())
:call-seq:
def boolean
  BooleanMatcher.new(nil)
end

def duck_type(*args)

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

== Examples

Passes if the argument responds to the specified messages.

object.should_receive(:message).with(duck_type(:hello, :goodbye))
object.should_receive(:message).with(duck_type(:hello))
:call-seq:
def duck_type(*args)
  DuckTypeMatcher.new(*args)
end

def hash_including(*args)

pairs. If the hash includes other keys, it will still pass.
Passes if the argument is a hash that includes the specified key(s) or key/value
object.should_receive(:message).with(hash_including(:key, :key2 => val2))
object.should_receive(:message).with(hash_including(:key))
object.should_receive(:message).with(hash_including(:key => val))
:call-seq:
def hash_including(*args)
  HashIncludingMatcher.new(anythingize_lonely_keys(*args))
end

def hash_not_including(*args)

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

object.should_receive(:message).with(hash_not_including(:key, :key2 => :val2))
object.should_receive(:message).with(hash_not_including(:key))
object.should_receive(:message).with(hash_not_including(:key => val))
:call-seq:
def hash_not_including(*args)
  HashNotIncludingMatcher.new(anythingize_lonely_keys(*args))
end

def instance_of(klass)

Passes if arg.instance_of?(klass)
def instance_of(klass)
  InstanceOf.new(klass)
end

def kind_of(klass)

Passes if arg.kind_of?(klass)
def kind_of(klass)
  KindOf.new(klass)
end

def no_args

Passes if no arguments are passed along with the message

object.should_receive(:message).with(no_args)
:call-seq:
def no_args
  NoArgsMatcher.new
end