Exception: Assay::CompareFailure

Inherits:
Assertion
  • Object
show all
Defined in:
lib/assay/assertions/compare_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/compare_failure.rb', line 7

def self.assertion_name
  :like
end

.pass?(exp, act) ⇒ Boolean

Test assertion.

Returns:

  • (Boolean)


12
13
14
15
16
17
# File 'lib/assay/assertions/compare_failure.rb', line 12

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

Instance Method Details

#to_sObject



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/assay/assertions/compare_failure.rb', line 20

def to_s
  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