Class: Riot::KindOfMacro

Inherits:
AssertionMacro show all
Defined in:
lib/riot/assertion_macros/kind_of.rb

Overview

Asserts that the result of the test is an object that is a kind of the expected type

asserts("test") { "foo" }.kind_of(String)
should("test") { "foo" }.kind_of(String)

Instance Method Summary collapse

Methods inherited from AssertionMacro

default, #error, expects_exception!, #expects_exception?, #fail, #pass, register

Instance Method Details

#evaluate(actual, expected) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/riot/assertion_macros/kind_of.rb', line 8

def evaluate(actual, expected)
  if actual.kind_of?(expected)
    pass("is a kind of #{expected.inspect}")
  else
    fail("expected kind of #{expected}, not #{actual.class.inspect}")
  end
end