Class: Lookout::Equalities::Array

Inherits:
Object show all
Defined in:
lib/lookout/equalities/array.rb

Instance Method Summary collapse

Methods inherited from Object

#message

Instance Method Details

#diff(expected, actual) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/lookout/equalities/array.rb', line 14

def diff(expected, actual)
  return if expected.size == 1 or not Array === actual
  Lookout::Diff::Formats::Unified.
    new(Lookout::Diff::Groups.
          new(Lookout::Diff::Operations.
                new(Lookout::Diff::Algorithms::Difflib.
                      new(actual, expected)))).to_a.join("\n")
end

#equal?(expected, actual) ⇒ Boolean

Returns:



6
7
8
9
10
11
12
# File 'lib/lookout/equalities/array.rb', line 6

def equal?(expected, actual)
  return false unless Array === actual and expected.size == actual.size
  expected.each_with_index do |v, i|
    return false unless Lookout::Equality.equal? v, actual[i]
  end
  true
end