Sha256: 62923b37b1afa98df961c5c07410fb302a605f13e5686c49e588610a8ad2b3d5
Contents?: true
Size: 1.68 KB
Versions: 1
Compression:
Stored size: 1.68 KB
Contents
require 'assay/assertions/compare_failure' module Assay class IdentityFailure < CompareFailure def self.assertion_name :identical end def self.assertion_operator :equal? end #def self.fail_message(exp, act) # "Expected #{act.inspect} to be identical to #{exp.inspect}" #end #def self.fail_message!(exp, act) # "Expected #{act.inspect} not to be identical to #{exp.inspect}" #end # Check assertion. def self.pass?(exp, act) exp.object_id == act.object_id 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} not to be identical to #{iexp}" else "Expected #{iact} to be identical to #{iexp}" end end end module Assertives # Passes if +actual+ .equal? +expected+ (i.e. they are the same instance). # # o = Object.new # assert_identical(o, o) # def assert_identical(exp, act, msg=nil) IdentityFailure.assert(exp, act, :message=>msg, :backtrace=>caller) end # Passes if ! actual .equal? expected # # assert_not_identical(Object.new, Object.new) # def assert_not_identical(exp, act, msg=nil) IdentityFailure.refute(exp, act, :message=>msg, :backtrace=>caller) end end module Matchers # # # object1.assert is_identical_to(object2) # def is_identical_to(obj) IdentityFailure.to_matcher(obj) end # # # object1.should be_identical_to(object2) # def be_identical_to(obj) IdentityFailure.to_matcher(obj) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
assay-0.3.0 | lib/assay/assertions/identity_failure.rb |