Class: Oval::KindOf

Inherits:
ClassDeclBase show all
Defined in:
lib/oval/kind_of.rb

Instance Attribute Summary

Attributes inherited from ClassDeclBase

#klass

Instance Method Summary collapse

Methods inherited from ClassDeclBase

[], #initialize

Methods inherited from Base

[], ensure_equal, #initialize, it_should, validate

Constructor Details

This class inherits a constructor from Oval::ClassDeclBase

Instance Method Details

#it_shouldObject



11
12
13
# File 'lib/oval/kind_of.rb', line 11

def it_should
  "be a kind of #{klass.name}"
end

#validate(object, subject = nil) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/oval/kind_of.rb', line 4

def validate(object, subject = nil)
  unless object.kind_of?(klass)
    raise Oval::ValueError,
      "Invalid object #{object.inspect} of type #{object.class.name}" +
      "#{for_subject(subject)}. Should be a kind of #{klass.name}"
  end
end