Exception: Assay::KindFailure

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

Overview

Comparison assertion for #kind_of?

KindFailure.pass?(1, Integer)  #=> true
KindFailure.fail?(1, String)   #=> true

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



12
13
14
# File 'lib/assay/assertions/kind_failure.rb', line 12

def self.assertion_name
  :kind_of
end

.assertion_operatorObject



16
17
18
# File 'lib/assay/assertions/kind_failure.rb', line 16

def self.assertion_operator
  :kind_of?
end

.pass?(exp, act) ⇒ Boolean

Check assertion.

Returns:

  • (Boolean)


21
22
23
# File 'lib/assay/assertions/kind_failure.rb', line 21

def self.pass?(exp, act)
  exp.kind_of? act
end

Instance Method Details

#to_sObject



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/assay/assertions/kind_failure.rb', line 26

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

  exp = @arguments[0].inspect
  act = @arguments[1].inspect

  if @_negated
    "Expected #{act} to be kind of #{exp}"
  else
    "Expected #{act} to be kind of #{exp}"
  end
end