module Rspec::Mocks::ArgumentMatchers
def any_args
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
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
object.should_receive(:message).with(boolean())
:call-seq:
def boolean BooleanMatcher.new(nil) end
def duck_type(*args)
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)
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)
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)
def instance_of(klass) InstanceOf.new(klass) end
def kind_of(klass)
def kind_of(klass) KindOf.new(klass) end
def no_args
object.should_receive(:message).with(no_args)
:call-seq:
def no_args NoArgsMatcher.new end