class MotionExpect::Matcher::MatchArray

Public Class Methods

new(expected_array) click to toggle source
# File lib/motion-expect/matcher/match_array.rb, line 3
def initialize(expected_array)
  @expected_array = expected_array
end

Public Instance Methods

fail!(subject_array, negated) click to toggle source
# File lib/motion-expect/matcher/match_array.rb, line 17
def fail!(subject_array, negated)
  raise FailedExpectation.new(FailMessageRenderer.message_for_match_array(negated, subject_array, @expected_array))
end
matches?(subject_array) click to toggle source
# File lib/motion-expect/matcher/match_array.rb, line 7
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