Sha256: 61bb5d56a1d88f4eaac06e45f0673e2af8552b0e5b98205f9127b79da95fd5b4

Contents?: true

Size: 907 Bytes

Versions: 1

Compression:

Stored size: 907 Bytes

Contents

require 'assay/assertion'

module Assay

  class CompareFailure < Assertion

    def self.assertion_name
      :like
    end

    # Test assertion.
    def self.pass?(exp, act)
      exp.equal?(act) ||
      exp.eq?(act)    ||
      exp.==(act)     ||
      exp.===(act)
    end

    #
    def to_s
      return @mesg if @mesg
      return super unless @arguments.size == 2

      iexp = @arguments[0].inspect
      iact = @arguments[1].inspect

      if @_negated
        "Expected #{iact} to NOT be like #{iexp}"
      else
        "Expected #{iact} to be like #{iexp}"
      end
    end

  end


  module Assertives

  end


  module Matchers
    #
    #
    #   object1.should be_like(object2)
    #
    def be_like(act)
      CompareFailure.to_matcher(act)
    end

    #
    #
    #   object1.should be_like(object2)
    #
    def is_like(act)
      CompareFailure.to_matcher(act)
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
assay-0.3.0 lib/assay/assertions/compare_failure.rb