Class: ArgumentSpecification::Matchers::Cover

Inherits:
BaseMatcher
  • Object
show all
Defined in:
lib/argspec/matchers/cover.rb

Instance Attribute Summary collapse

Attributes inherited from BaseMatcher

#actual, #metadata

Instance Method Summary collapse

Methods inherited from BaseMatcher

#failure_message, #failure_message_when_negated, matcher_name

Constructor Details

#initialize(*values) ⇒ Cover

Create a new matcher instance

Arguments:

values: (Splat)

Example:

>> ArgumentSpecification::Matchers::Cover.new(1, 2)
=> #<ArgumentSpecification::Matchers::Cover:0x00000000000000 @values=[1, 2]>


17
18
19
# File 'lib/argspec/matchers/cover.rb', line 17

def initialize(*values)
  @values = values
end

Instance Attribute Details

#valuesObject (readonly)

Returns the value of attribute values.



6
7
8
# File 'lib/argspec/matchers/cover.rb', line 6

def values
  @values
end

Instance Method Details

#matches?Boolean

Check if the actual object matches

Example:

>> matcher.matches?
=> true

Returns:

  • (Boolean)


27
28
29
30
31
32
33
# File 'lib/argspec/matchers/cover.rb', line 27

def matches?
  @values.each do |value|
    return false unless @actual.include?(value)
  end

  true
end