Module: RubyUnit::Assertions::Classes
- Includes:
- RubyUnit::AssertionMessage, Root
- Included in:
- RubyUnit::Assertions
- Defined in:
- lib/RubyUnit/Assertions/Classes.rb
Constant Summary
Constants included from RubyUnit::AssertionMessage
RubyUnit::AssertionMessage::ASSERT_CLASS_METHOD_ERROR, RubyUnit::AssertionMessage::ASSERT_CONST_DEFINED_ERROR, RubyUnit::AssertionMessage::ASSERT_CONST_ERROR, RubyUnit::AssertionMessage::ASSERT_CONST_NOT_DEFINED_ERROR, RubyUnit::AssertionMessage::ASSERT_DESCENDENT_ERROR, RubyUnit::AssertionMessage::ASSERT_EMPTY_ERROR, RubyUnit::AssertionMessage::ASSERT_EQUAL_ERROR, RubyUnit::AssertionMessage::ASSERT_ERROR, RubyUnit::AssertionMessage::ASSERT_FALSE_ERROR, RubyUnit::AssertionMessage::ASSERT_GREATERTHANOREQUAL_ERROR, RubyUnit::AssertionMessage::ASSERT_GREATERTHAN_ERROR, RubyUnit::AssertionMessage::ASSERT_INCLUDE_ERROR, RubyUnit::AssertionMessage::ASSERT_INSTANCE_METHOD_ERROR, RubyUnit::AssertionMessage::ASSERT_INSTANCE_OF_ERROR, RubyUnit::AssertionMessage::ASSERT_INSTANCE_VARIABLE_DEFINED_ERROR, RubyUnit::AssertionMessage::ASSERT_INSTANCE_VARIABLE_EQUAL_ERROR, RubyUnit::AssertionMessage::ASSERT_INSTANCE_VARIABLE_KIND_OF_ERROR, RubyUnit::AssertionMessage::ASSERT_INSTANCE_VARIABLE_NOT_DEFINED_ERROR, RubyUnit::AssertionMessage::ASSERT_INSTANCE_VARIABLE_NOT_EQUAL_ERROR, RubyUnit::AssertionMessage::ASSERT_INSTANCE_VARIABLE_NOT_KIND_OF_ERROR, RubyUnit::AssertionMessage::ASSERT_KIND_OF_ERROR, RubyUnit::AssertionMessage::ASSERT_LESSTHANOREQUAL_ERROR, RubyUnit::AssertionMessage::ASSERT_LESSTHAN_ERROR, RubyUnit::AssertionMessage::ASSERT_MATCH_ERROR, RubyUnit::AssertionMessage::ASSERT_METHOD_ERROR, RubyUnit::AssertionMessage::ASSERT_NIL_ERROR, RubyUnit::AssertionMessage::ASSERT_NOTHING_RAISED_ERROR, RubyUnit::AssertionMessage::ASSERT_NOT_CLASS_METHOD_ERROR, RubyUnit::AssertionMessage::ASSERT_NOT_DESCENDENT_ERROR, RubyUnit::AssertionMessage::ASSERT_NOT_EMPTY_ERROR, RubyUnit::AssertionMessage::ASSERT_NOT_EQUAL_ERROR, RubyUnit::AssertionMessage::ASSERT_NOT_ERROR, RubyUnit::AssertionMessage::ASSERT_NOT_INCLUDE_ERROR, RubyUnit::AssertionMessage::ASSERT_NOT_INSTANCE_METHOD_ERROR, RubyUnit::AssertionMessage::ASSERT_NOT_INSTANCE_OF_ERROR, RubyUnit::AssertionMessage::ASSERT_NOT_KIND_OF_ERROR, RubyUnit::AssertionMessage::ASSERT_NOT_MATCH_ERROR, RubyUnit::AssertionMessage::ASSERT_NOT_METHOD_ERROR, RubyUnit::AssertionMessage::ASSERT_NOT_NIL_ERROR, RubyUnit::AssertionMessage::ASSERT_NOT_RESPOND_TO_ERROR, RubyUnit::AssertionMessage::ASSERT_NOT_SAME_ERROR, RubyUnit::AssertionMessage::ASSERT_RAISE_ERROR, RubyUnit::AssertionMessage::ASSERT_RAISE_EXPECTED_ERROR, RubyUnit::AssertionMessage::ASSERT_RAISE_KIND_OF_ERROR, RubyUnit::AssertionMessage::ASSERT_RAISE_MESSAGE_ERROR, RubyUnit::AssertionMessage::ASSERT_RESPOND_TO_ERROR, RubyUnit::AssertionMessage::ASSERT_SAME_ERROR, RubyUnit::AssertionMessage::ASSERT_TRUE_ERROR, RubyUnit::AssertionMessage::FAILING, RubyUnit::AssertionMessage::FAILURE
Instance Method Summary collapse
-
#assertConst(expected, klass, konstant, message = nil) ⇒ Object
Assert that a constant is defined correctly in the correct class * raises RubyUnit::AssertionFailure unless the constant is defined in the specified class and it is the correct type and value.
-
#assertConstDefined(klass, konstant, message = nil) ⇒ Object
Assert that a constant is defined in the specified class * raises RubyUnit::AssertionFailure unless the constant is defined in the specified class.
-
#assertConstNotDefined(klass, konstant, message = nil) ⇒ Object
Assert that a constant is not defined in the specified class * raises RubyUnit::AssertionFailure if the constant is defined in the specified class.
-
#assertDescendent(_super, descendent, message = nil) ⇒ Object
Assert that a class is a descendent of another class * raises RubyUnit::AssertionFailure unless descendent is a descendent of
_super
. -
#assertInstanceOf(klass, object, message = nil) ⇒ Object
Assert that an object is an instance of a specified class * raises RubyUnit::AssertionFailure unless object is an instance of klass.
-
#assertKindOf(klass, object, message = nil) ⇒ Object
(also: #assertIsA)
Assert that an object is an instance of the specified class or one of its descendents.
-
#assertNotDescendent(klass, descendent, message = nil) ⇒ Object
Assert that a class is not a descendent of another class * raises RubyUnit::AssertionFailure if klass is a descendent of klass.
-
#assertNotInstanceOf(exclusion, object, message = nil) ⇒ Object
Assert that an object is an instance of a specified class * raises RubyUnit::AssertionFailure unless object is an instance of klass.
-
#assertNotKindOf(exclusion, object, message = nil) ⇒ Object
Assert that an object is not an instance of the specified class or one of its descendents.
Instance Method Details
#assertConst(expected, klass, konstant, message = nil) ⇒ Object
Assert that a constant is defined correctly in the correct class
-
raises RubyUnit::AssertionFailure unless the constant is defined in the specified class and it is the correct type and value
- expected
-
The value that is expected for the constant
- klass
-
The class where the constant should be defined
- konstant
-
The name of the constant
- message
-
The message provided to be reported for a failure
assertConst 42, Numbers, 'TWENTYFOUR', 'So dyslexic.' # => fail
156 157 158 159 160 161 162 163 |
# File 'lib/RubyUnit/Assertions/Classes.rb', line 156 def assertConst expected, klass, konstant, = nil __assert_block ASSERT_CONST_ERROR, do assertConstDefined klass, konstant, value = klass.const_get konstant assertKindOf expected.class, value, assertEqual expected, value, end end |
#assertConstDefined(klass, konstant, message = nil) ⇒ Object
Assert that a constant is defined in the specified class
-
raises RubyUnit::AssertionFailure unless the constant is defined in the specified class
- klass
-
The class where the constant should be defined
- konstant
-
The name of the constant
- message
-
The message provided to be reported for a failure
assertConstDefined Numbers, 'FORTYTWO', 'Mystery.' # => ??
181 182 183 |
# File 'lib/RubyUnit/Assertions/Classes.rb', line 181 def assertConstDefined klass, konstant, = nil __assert (klass.const_defined? konstant), ASSERT_CONST_DEFINED_ERROR, , {:klass=>klass, :konstant=>konstant} end |
#assertConstNotDefined(klass, konstant, message = nil) ⇒ Object
Assert that a constant is not defined in the specified class
-
raises RubyUnit::AssertionFailure if the constant is defined in the specified class
- klass
-
The class where the constant should not be defined
- konstant
-
The name of the constant
- message
-
The message provided to be reported for a failure
assertConstNotDefined Numbers, 'TWENTYFOUR', 'Mystery.' # => ??
201 202 203 |
# File 'lib/RubyUnit/Assertions/Classes.rb', line 201 def assertConstNotDefined klass, konstant, = nil __reject (klass.const_defined? konstant), ASSERT_CONST_NOT_DEFINED_ERROR, , {:klass=>klass, :konstant=>konstant} end |
#assertDescendent(_super, descendent, message = nil) ⇒ Object
Assert that a class is a descendent of another class
-
raises RubyUnit::AssertionFailure unless descendent is a descendent of
_super
- _super
-
The parent class
- descendent
-
The descendent class
- message
-
The message provided to be reported for a failure
assertDescendent Numeric, Exception, 'Nope' # => fail
110 111 112 113 114 |
# File 'lib/RubyUnit/Assertions/Classes.rb', line 110 def assertDescendent _super, descendent, = nil __assert_descendent ASSERT_DESCENDENT_ERROR, _super, descendent, do descendent < _super end end |
#assertInstanceOf(klass, object, message = nil) ⇒ Object
Assert that an object is an instance of a specified class
-
raises RubyUnit::AssertionFailure unless object is an instance of klass.
- klass
-
The class that is expected
- object
-
The object that will be checked against klass
- message
-
The message provided to be reported for a failure
assertInstanceOf Integer, '25', 'So close, but... No.' # => fail
72 73 74 |
# File 'lib/RubyUnit/Assertions/Classes.rb', line 72 def assertInstanceOf klass, object, = nil __assert (object.instance_of? klass), ASSERT_INSTANCE_OF_ERROR, , {:klass=>klass, :object=>object} end |
#assertKindOf(klass, object, message = nil) ⇒ Object Also known as: assertIsA
Assert that an object is an instance of the specified class or one of its descendents.
-
raises RubyUnit::AssertionFailure unless object is an instance of klass or one of its descendents.
- klass
-
The class that is expected
- object
-
The object that will be checked against klass
- message
-
The message provided to be reported for a failure
assertKindOf String, 25, 'Nope, try again.' # => fail
26 27 28 |
# File 'lib/RubyUnit/Assertions/Classes.rb', line 26 def assertKindOf klass, object, = nil __assert (object.is_a? klass), ASSERT_KIND_OF_ERROR, , {:klass=>klass, :object=>object} end |
#assertNotDescendent(klass, descendent, message = nil) ⇒ Object
Assert that a class is not a descendent of another class
-
raises RubyUnit::AssertionFailure if klass is a descendent of klass
- klass
-
The parent class
- descendent
-
The illegal descendent class
- message
-
The message provided to be reported for a failure
assertDescendent StandardError, Exception, 'It is' # => fail
131 132 133 134 135 |
# File 'lib/RubyUnit/Assertions/Classes.rb', line 131 def assertNotDescendent klass, descendent, = nil __assert_descendent ASSERT_NOT_DESCENDENT_ERROR, klass, descendent, do not descendent < klass end end |
#assertNotInstanceOf(exclusion, object, message = nil) ⇒ Object
Assert that an object is an instance of a specified class
-
raises RubyUnit::AssertionFailure unless object is an instance of klass.
- exclusion
-
The class that is expected
- object
-
The object that will be checked against klass
- message
-
The message provided to be reported for a failure
assertNotInstanceOf Integer, 25, 'So close, but... No.' # => fail
91 92 93 |
# File 'lib/RubyUnit/Assertions/Classes.rb', line 91 def assertNotInstanceOf exclusion, object, = nil __reject (object.instance_of? exclusion), ASSERT_NOT_INSTANCE_OF_ERROR, , {:exclusion=>exclusion, :object=>object} end |
#assertNotKindOf(exclusion, object, message = nil) ⇒ Object
Assert that an object is not an instance of the specified class or one of its descendents.
-
raises RubyUnit::AssertionFailure if object is an instance of exclusion or
one of its descendents.
- exclusion
-
The class that is excluded
- object
-
The object that will be checked against klass
- message
-
The message provided to be reported for a failure
assertNotKindOf Numeric, 25, 'Nope, try again.' # => fail
49 50 51 |
# File 'lib/RubyUnit/Assertions/Classes.rb', line 49 def assertNotKindOf exclusion, object, = nil __reject (object.is_a? exclusion), ASSERT_NOT_KIND_OF_ERROR, , {:exclusion=>exclusion, :object=>object} end |