class EqualAssay

EqualAssay coers the assertion comparing two objects with ‘#==` operator.

Public Class Methods

assert_message(subject, criterion) click to toggle source

Error message for equal assertion.

# File lib/assay/equal_assay.rb, line 19
def self.assert_message(subject, criterion)
  a = subject.inspect
  b = criterion.inspect

  if a.size > SIZE_LIMIT or b.size > SIZE_LIMIT
    if $ansi
      d = ANSI::Diff.new(a, b)
      a, b = d.diff1, d.diff2  # *d.to_a
    end
    "a == b\na) #{a}\nb) #{b}"
  else
    "#{a} == #{b}"
  end
end
pass?(subject, criterion) click to toggle source

Test assertion of ‘#==` method.

# File lib/assay/equal_assay.rb, line 12
def self.pass?(subject, criterion)
  subject == criterion
end