module RSpec::Mocks::ArgumentMatchers

def any_args

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

@example

`object.should_receive(:message)`
Matches any args at all. Supports a more explicit variation of
def any_args
  AnyArgsMatcher.new
end

def anything

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

@example

Matches any argument at all.
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

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

@example

Matches a boolean value.
def boolean
  BooleanMatcher.new(nil)
end

def duck_type(*args)

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

@example

Matches if the actual argument responds to the specified messages.
def duck_type(*args)
  DuckTypeMatcher.new(*args)
end

def hash_excluding(*args)

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

@example

Matches a hash that doesn't include the specified key(s) or key/value.
def hash_excluding(*args)
  HashExcludingMatcher.new(anythingize_lonely_keys(*args))
end

def hash_including(*args)

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))

@example

Ignores any additional keys.
Matches a hash that includes the specified key(s) or key/value pairs.
def hash_including(*args)
  HashIncludingMatcher.new(anythingize_lonely_keys(*args))
end

def instance_of(klass)

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

@example

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

def kind_of(klass)

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

@example
Matches if `arg.kind_of?(klass)`
def kind_of(klass)
  KindOf.new(klass)
end

def no_args

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

@example

Matches no arguments.
def no_args
  NoArgsMatcher.new
end