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.
Passes if object receives :message with any args at all. This is really a more explicit variation of object.should_receive(:message)
# File lib/rspec/mocks/argument_matchers.rb, line 146 def any_args AnyArgsMatcher.new end
Passes as long as there is an argument.
# File lib/rspec/mocks/argument_matchers.rb, line 154 def anything AnyArgMatcher.new(nil) end
Passes if the argument is boolean.
# File lib/rspec/mocks/argument_matchers.rb, line 186 def boolean BooleanMatcher.new(nil) end
Passes if the argument responds to the specified messages.
array = [] display = double('display') display.should_receive(:present_names).with(duck_type(:length, :each)) => passes
# File lib/rspec/mocks/argument_matchers.rb, line 178 def duck_type(*args) DuckTypeMatcher.new(*args) end
# File lib/rspec/mocks/argument_matchers.rb, line 196 def hash_including(*args) HashIncludingMatcher.new(anythingize_lonely_keys(*args)) end
Passes if the argument is a hash that doesn't include the specified key(s) or key/value
# File lib/rspec/mocks/argument_matchers.rb, line 206 def hash_not_including(*args) HashNotIncludingMatcher.new(anythingize_lonely_keys(*args)) end
Passes if arg.instance_of?(klass)
# File lib/rspec/mocks/argument_matchers.rb, line 211 def instance_of(klass) InstanceOf.new(klass) end
Passes if arg.kind_of?(klass)
# File lib/rspec/mocks/argument_matchers.rb, line 218 def kind_of(klass) KindOf.new(klass) end
Generated with the Darkfish Rdoc Generator 2.