Module: RSpec::Mocks::ArgumentMatchers
Relationships & Source Files | |
Namespace Children | |
Classes:
| |
Extension / Inclusion / Inheritance Descendants | |
Included In:
| |
Defined in: | rspec-mocks/lib/rspec/mocks/argument_matchers.rb |
Overview
Class Method Summary
- .anythingize_lonely_keys(*args) Internal use only Internal use only
Instance Method Summary
-
#a_kind_of(klass)
Alias for #kind_of.
-
#an_instance_of(klass)
Alias for #instance_of.
-
#any_args
Acts like an arg splat, matching any number of args at any point in an arg list.
-
#anything
Matches any argument at all.
-
#array_excluding(*args)
Matches an array that excludes the specified items.
-
#array_including(*args)
Matches an array that includes the specified items at least once.
-
#boolean
Matches a boolean value.
-
#duck_type(*args)
Matches if the actual argument responds to the specified messages.
-
#hash_excluding(*args)
(also: #hash_not_including)
Matches a hash that doesn’t include the specified key(s) or key/value.
-
#hash_including(*args)
Matches a hash that includes the specified key(s) or key/value pairs.
-
#hash_not_including(*args)
Alias for #hash_excluding.
-
#instance_of(klass)
(also: #an_instance_of)
Matches if ‘arg.instance_of?(klass)`.
-
#kind_of(klass)
(also: #a_kind_of)
Matches if ‘arg.kind_of?(klass)`.
-
#no_args
Matches no arguments.
Class Method Details
.anythingize_lonely_keys(*args)
# File 'rspec-mocks/lib/rspec/mocks/argument_matchers.rb', line 128
def self.anythingize_lonely_keys(*args) hash = Hash === args.last ? args.delete_at(-1) : {} args.each { | arg | hash[arg] = AnyArgMatcher::INSTANCE } hash end
Instance Method Details
#a_kind_of(klass)
Alias for #kind_of.
# File 'rspec-mocks/lib/rspec/mocks/argument_matchers.rb', line 125
alias_method :a_kind_of, :kind_of
#an_instance_of(klass)
Alias for #instance_of.
# File 'rspec-mocks/lib/rspec/mocks/argument_matchers.rb', line 115
alias_method :an_instance_of, :instance_of
#any_args
Acts like an arg splat, matching any number of args at any point in an arg list.
# File 'rspec-mocks/lib/rspec/mocks/argument_matchers.rb', line 26
def any_args AnyArgsMatcher::INSTANCE end
#anything
Matches any argument at all.
# File 'rspec-mocks/lib/rspec/mocks/argument_matchers.rb', line 34
def anything AnyArgMatcher::INSTANCE end
#array_excluding(*args)
Matches an array that excludes the specified items.
# File 'rspec-mocks/lib/rspec/mocks/argument_matchers.rb', line 100
def array_excluding(*args) actually_an_array = Array === args.first && args.count == 1 ? args.first : args ArrayExcludingMatcher.new(actually_an_array) end
#array_including(*args)
Matches an array that includes the specified items at least once. Ignores duplicates and additional values
# File 'rspec-mocks/lib/rspec/mocks/argument_matchers.rb', line 90
def array_including(*args) actually_an_array = Array === args.first && args.count == 1 ? args.first : args ArrayIncludingMatcher.new(actually_an_array) end
#boolean
Matches a boolean value.
# File 'rspec-mocks/lib/rspec/mocks/argument_matchers.rb', line 59
def boolean BooleanMatcher::INSTANCE end
#duck_type(*args)
Matches if the actual argument responds to the specified messages.
# File 'rspec-mocks/lib/rspec/mocks/argument_matchers.rb', line 51
def duck_type(*args) DuckTypeMatcher.new(*args) end
#hash_excluding(*args) Also known as: #hash_not_including
Matches a hash that doesn’t include the specified key(s) or key/value.
# File 'rspec-mocks/lib/rspec/mocks/argument_matchers.rb', line 80
def hash_excluding(*args) HashExcludingMatcher.new(ArgumentMatchers.anythingize_lonely_keys(*args)) end
#hash_including(*args)
Matches a hash that includes the specified key(s) or key/value pairs. Ignores any additional keys.
# File 'rspec-mocks/lib/rspec/mocks/argument_matchers.rb', line 70
def hash_including(*args) HashIncludingMatcher.new(ArgumentMatchers.anythingize_lonely_keys(*args)) end
#hash_not_including(*args)
Alias for #hash_excluding.
# File 'rspec-mocks/lib/rspec/mocks/argument_matchers.rb', line 105
alias_method :hash_not_including, :hash_excluding
#instance_of(klass) Also known as: #an_instance_of
Matches if ‘arg.instance_of?(klass)`
# File 'rspec-mocks/lib/rspec/mocks/argument_matchers.rb', line 111
def instance_of(klass) InstanceOf.new(klass) end
#kind_of(klass) Also known as: #a_kind_of
Matches if ‘arg.kind_of?(klass)`
#no_args
Matches no arguments.
# File 'rspec-mocks/lib/rspec/mocks/argument_matchers.rb', line 42
def no_args NoArgsMatcher::INSTANCE end