class ArrayHandler

Public Instance Methods

intersection() click to toggle source
# File lib/human_reporter.rb, line 56
def intersection
  @intersection ||= expected & actual
end
message() click to toggle source
# File lib/human_reporter.rb, line 68
def message
  result = ""
  print_with_colour(RED, result, expected, "Expected", intersection)
  print_with_colour(GREEN, result, actual, "  Actual", intersection)

  if missing.any? || remaining.any?
    result << "\n"

    result << "   Missing: #{missing.inspect}\n" unless missing.empty?
    result << " Remaining: #{remaining.inspect}\n" unless remaining.empty?
  end

  if expected.to_set == actual.to_set
    result << "\n    Both arrays have the same elements, but order matters in array comparisons."
    result << " If element order does not matter, you can call '.to_set' on both before asserting.\n"
  end

  result
end
missing() click to toggle source
# File lib/human_reporter.rb, line 60
def missing
  @missing ||= expected - intersection
end
remaining() click to toggle source
# File lib/human_reporter.rb, line 64
def remaining
  @remaining ||= actual - intersection
end

Private Instance Methods

print_with_colour(colour, message, enumerable, title, intersection) click to toggle source