Class: Crspec::Matchers::MatchArrayMatcher
- Inherits:
-
BaseMatcher
- Object
- BaseMatcher
- Crspec::Matchers::MatchArrayMatcher
- Defined in:
- lib/crspec/matchers.rb
Instance Attribute Summary
Attributes inherited from BaseMatcher
Instance Method Summary collapse
Methods inherited from BaseMatcher
#and, #failure_message_when_negated, #initialize, #or
Constructor Details
This class inherits a constructor from Crspec::Matchers::BaseMatcher
Instance Method Details
#failure_message ⇒ Object
449 450 451 |
# File 'lib/crspec/matchers.rb', line 449 def "Expected #{@actual.inspect} to contain exactly #{@expected.inspect} (in any order)" end |
#matches?(actual) ⇒ Boolean
438 439 440 441 442 443 444 445 446 447 |
# File 'lib/crspec/matchers.rb', line 438 def matches?(actual) @actual = actual return false unless actual.respond_to?(:to_a) remaining = actual.to_a.dup @expected.all? do |item| idx = remaining.index { |el| item == el || item === el } idx ? remaining.delete_at(idx) && true : false end && remaining.empty? end |