Class: MotionSpec::Matcher::MatchArray
- Defined in:
- lib/motion-spec/matcher/match_array.rb
Instance Method Summary collapse
- #fail!(subject_array, negated) ⇒ Object
-
#initialize(expected_array) ⇒ MatchArray
constructor
A new instance of MatchArray.
- #matches?(subject_array) ⇒ Boolean
Constructor Details
#initialize(expected_array) ⇒ MatchArray
Returns a new instance of MatchArray.
5 6 7 |
# File 'lib/motion-spec/matcher/match_array.rb', line 5 def initialize(expected_array) @expected_array = expected_array end |
Instance Method Details
#fail!(subject_array, negated) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/motion-spec/matcher/match_array.rb', line 19 def fail!(subject_array, negated) raise FailedExpectation.new( FailMessageRenderer.( negated, subject_array, @expected_array ) ) end |
#matches?(subject_array) ⇒ Boolean
9 10 11 12 13 14 15 16 17 |
# File 'lib/motion-spec/matcher/match_array.rb', line 9 def matches?(subject_array) return false unless subject_array.size == @expected_array.size array_copy = subject_array.dup @expected_array.all? do |item| has = array_copy.include?(item) array_copy.delete(item) if has has end end |