Sha256: 9caa054694c8bba041ee5df4364b9574835a6bca5baa7cb39bfcc1b3bcbda7a5

Contents?: true

Size: 852 Bytes

Versions: 3

Compression:

Stored size: 852 Bytes

Contents

require "object_comparator/version"

class ObjectComparator
  def equal?(one, other)
    one = InspectionString.new(one.inspect)
    other = InspectionString.new(other.inspect)
    one == other
  end

  def failing_message_for_should(one, other)
    one = InspectionString.new(one.inspect)
    other = InspectionString.new(other.inspect)

    "expected #{other} to be equal to #{one}"
  end

  def failing_message_for_should_not(one, other)
    one = InspectionString.new(one.inspect)
    other = InspectionString.new(other.inspect)

    "expected #{other} not to be equal to #{one}"
  end

  class InspectionString
    def initialize(string)
      @string = string
    end

    def ==(other)
      other.to_s == to_s
    end

    def to_s
      @string.gsub(/:0x[a-z0-9]{14,16} /, ' ')
             .gsub(/:0x[a-z0-9]{14,16}>/, '>')
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
object_comparator-0.1.4 lib/object_comparator.rb
object_comparator-0.1.3 lib/object_comparator.rb
object_comparator-0.1.2 lib/object_comparator.rb