Class: ArgumentSpecification::Matchers::Cover
- Inherits:
-
BaseMatcher
- Object
- BaseMatcher
- ArgumentSpecification::Matchers::Cover
- Defined in:
- lib/argspec/matchers/cover.rb
Instance Attribute Summary collapse
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Attributes inherited from BaseMatcher
Instance Method Summary collapse
-
#initialize(*values) ⇒ Cover
constructor
Create a new matcher instance.
-
#matches? ⇒ Boolean
Check if the actual object matches.
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(:a, :b)
=> #<ArgumentSpecification::Matchers::Cover:0x00000000000000 @values=[:a, :b]>
17 18 19 |
# File 'lib/argspec/matchers/cover.rb', line 17 def initialize(*values) @values = values end |
Instance Attribute Details
#values ⇒ Object (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
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/argspec/matchers/cover.rb', line 27 def matches? symbol = @actual.is_a?(Symbol) actual = symbol ? @actual.to_s : @actual values = symbol ? @values.map { |v| v.is_a?(Symbol) ? v.to_s : v } : @values values.each do |value| return false unless actual.include?(value) end true end |