Class: ElabsMatchers::Matchers::OnlyInclude::OnlyIncludeMatcher
- Inherits:
-
Struct
- Object
- Struct
- ElabsMatchers::Matchers::OnlyInclude::OnlyIncludeMatcher
- Defined in:
- lib/elabs_matchers/matchers/only_include.rb
Instance Attribute Summary collapse
-
#actual ⇒ Object
readonly
Returns the value of attribute actual.
-
#elements ⇒ Object
Returns the value of attribute elements.
Instance Method Summary collapse
- #failure_message ⇒ Object (also: #failure_message_for_should)
- #failure_message_when_negated ⇒ Object (also: #failure_message_for_should_not)
- #matches?(actual) ⇒ Boolean
Instance Attribute Details
#actual ⇒ Object (readonly)
Returns the value of attribute actual
7 8 9 |
# File 'lib/elabs_matchers/matchers/only_include.rb', line 7 def actual @actual end |
#elements ⇒ Object
Returns the value of attribute elements
6 7 8 |
# File 'lib/elabs_matchers/matchers/only_include.rb', line 6 def elements @elements end |
Instance Method Details
#failure_message ⇒ Object Also known as: failure_message_for_should
16 17 18 |
# File 'lib/elabs_matchers/matchers/only_include.rb', line 16 def "Expected #{actual.inspect} to only include #{elements.inspect}." end |
#failure_message_when_negated ⇒ Object Also known as: failure_message_for_should_not
21 22 23 |
# File 'lib/elabs_matchers/matchers/only_include.rb', line 21 def "Expected #{actual.inspect} to not only include #{elements.inspect}, but it did." end |
#matches?(actual) ⇒ Boolean
9 10 11 12 13 14 |
# File 'lib/elabs_matchers/matchers/only_include.rb', line 9 def matches?(actual) @actual = actual elements.uniq.length == elements.length and actual.length == elements.length and elements.all? { |element| actual.include?(element) } end |