Sha256: 4830425e8e3542c5760eda2eac894944807a11a87ef55ec8794e3d31073e32e2

Contents?: true

Size: 656 Bytes

Versions: 2

Compression:

Stored size: 656 Bytes

Contents

require_relative 'like_assay'

# EqualAssay coers the assertion comparing two objects with `#==` operator.
#
class EqualAssay < LikeAssay

  register :==, :equal

  #
  # Test assertion of `#==` method.
  #
  def self.pass?(subject, criterion)
    subject == criterion
  end

  #
  # Error message for equal assertion.
  #
  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

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
assay-0.4.1 lib/assay/equal_assay.rb
assay-0.4.0 lib/assay/equal_assay.rb