class HashHandler

Public Instance Methods

intersection() click to toggle source
# File lib/human_reporter.rb, line 110
def intersection
  @intersection ||= expected.select do |key, value|
    actual.key?(key) && actual[key] == value
  end
end
message() click to toggle source
# File lib/human_reporter.rb, line 128
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

  result
end
missing() click to toggle source
# File lib/human_reporter.rb, line 116
def missing
  @missing ||= expected.reject do |key, value|
    intersection.key?(key) && intersection[key] == value
  end
end
remaining() click to toggle source
# File lib/human_reporter.rb, line 122
def remaining
  @remaining ||= actual.reject do |key, value|
    intersection.key?(key) && intersection[key] == value
  end
end

Private Instance Methods

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