Class: Object

Inherits:
BasicObject
Defined in:
lib/code-assertions.rb

Instance Method Summary collapse

Instance Method Details

#assert_not_nil!Object Also known as: assert_nn!



45
46
47
48
49
# File 'lib/code-assertions.rb', line 45

def assert_not_nil!
    assert("The result cannot be `nil` or `false`.") { self }
    
    self
end

#assert_type!(type) ⇒ Object Also known as: at!, is_a!



52
53
54
55
56
57
# File 'lib/code-assertions.rb', line 52

def assert_type!(type)
    assert("`type` should be an instance of `Class`") { type.is_a?(Class) }
    assert("Wrong type: expected #{type.name}, given #{self.class.name}") { self.is_a?(type) }
    
    self
end