Exception: Assay::IdentityFailure

Inherits:
CompareFailure show all
Defined in:
lib/assay/assertions/identity_failure.rb

Constant Summary

Constants inherited from Assertion

Assertion::SIZE_LIMIT

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Assertion

assert, #assert, assertable_method, #assertion?, #fail?, fail?, #initialize, #negative?, #pass?, refute, #refute, #set_arguments, #set_negative, to_matcher

Constructor Details

This class inherits a constructor from Assay::Assertion

Class Method Details

.assertion_nameObject



7
8
9
# File 'lib/assay/assertions/identity_failure.rb', line 7

def self.assertion_name
  :identical
end

.assertion_operatorObject



11
12
13
# File 'lib/assay/assertions/identity_failure.rb', line 11

def self.assertion_operator
  :equal?
end

.pass?(exp, act) ⇒ Boolean

Check assertion.

Returns:

  • (Boolean)


24
25
26
# File 'lib/assay/assertions/identity_failure.rb', line 24

def self.pass?(exp, act)
  exp.object_id == act.object_id
end

Instance Method Details

#to_sObject



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/assay/assertions/identity_failure.rb', line 29

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