Module: RubyUnit::Assertions::Comparisons
- Includes:
- RubyUnit::AssertionMessage, Root
- Included in:
- RubyUnit::Assertions
- Defined in:
- lib/RubyUnit/Assertions/Comparisons.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
-
#assertEqual(expected, actual, message = nil) ⇒ Object
Assert that two values are equal.
-
#assertGreaterThan(greater, value, message = nil) ⇒ Object
Assert that one value is greater than another.
-
#assertGreaterThanOrEqual(greater, value, message = nil) ⇒ Object
Assert that one value is greater than another.
-
#assertLessThan(less, value, message = nil) ⇒ Object
Assert that one value is less than another.
-
#assertLessThanOrEqual(less, value, message = nil) ⇒ Object
Assert that one value is less than another.
-
#assertMatch(pattern, value, message = nil) ⇒ Object
Assert that a value matches a Regexp pattern.
-
#assertNotEqual(illegal, actual, message = nil) ⇒ Object
Assert that two values are NOT equal.
-
#assertNotMatch(exclusion, value, message = nil) ⇒ Object
Assert that a value does not match a Regexp pattern.
-
#assertNotSame(illegal, actual, message = nil) ⇒ Object
Assert that two objects are not the same object * raises RubyUnit::AssertionFailure if illegal and actual are the same object.
-
#assertSame(expected, actual, message = nil) ⇒ Object
Assert that two objects are the same object * raises RubyUnit::AssertionFailure unless expected and actual are the same object.
Instance Method Details
#assertEqual(expected, actual, message = nil) ⇒ Object
Assert that two values are equal.
-
raises RubyUnit::AssertionFailure unless expected equals actual
- expected
-
The value that is forbidden by the assertion
- actual
-
The value that is being checked by the assertion
- message
-
The message provided to be reported for a failure
assertEqual 42, 24, "This will fail" # => fail
24 25 26 |
# File 'lib/RubyUnit/Assertions/Comparisons.rb', line 24 def assertEqual expected, actual, = nil __assert (expected == actual), ASSERT_EQUAL_ERROR, , {:expected=>expected, :actual=>actual} end |
#assertGreaterThan(greater, value, message = nil) ⇒ Object
Assert that one value is greater than another.
-
raises RubyUnit::AssertionFailure unless greater is greater than value
- greater
-
The value that should be greater
- value
-
The value that is being checked by the assertion
- message
-
The message provided to be reported for a failure
assertGreaterThan 24, 42, "This will fail" # => fail
62 63 64 |
# File 'lib/RubyUnit/Assertions/Comparisons.rb', line 62 def assertGreaterThan greater, value, = nil __assert (greater > value), ASSERT_GREATERTHAN_ERROR, , {:greater=>greater, :value=>value} end |
#assertGreaterThanOrEqual(greater, value, message = nil) ⇒ Object
Assert that one value is greater than another.
-
raises RubyUnit::AssertionFailure unless greater is greater than or equal to value
- greater
-
The value that should be greater than or equal
- value
-
The value that is being checked by the assertion
- message
-
The message provided to be reported for a failure
assertGreaterThanOrEqual 24, 42, "This will fail" # => fail
81 82 83 |
# File 'lib/RubyUnit/Assertions/Comparisons.rb', line 81 def assertGreaterThanOrEqual greater, value, = nil __assert (greater >= value), ASSERT_GREATERTHANOREQUAL_ERROR, , {:greater=>greater, :value=>value} end |
#assertLessThan(less, value, message = nil) ⇒ Object
Assert that one value is less than another.
-
raises RubyUnit::AssertionFailure unless less is less than value
- less
-
The value that should be less
- value
-
The value that is being checked by the assertion
- message
-
The message provided to be reported for a failure
assertLessThan 42, 24, "This will fail" # => fail
100 101 102 |
# File 'lib/RubyUnit/Assertions/Comparisons.rb', line 100 def assertLessThan less, value, = nil __assert (less < value), ASSERT_LESSTHAN_ERROR, , {:less=>less, :value=>value} end |
#assertLessThanOrEqual(less, value, message = nil) ⇒ Object
Assert that one value is less than another.
-
raises RubyUnit::AssertionFailure unless less is less than or equal to value
- less
-
The value that should be less than or equal
- value
-
The value that is being checked by the assertion
- message
-
The message provided to be reported for a failure
assertLessThanOrEqual 42, 24, "This will fail" # => fail
119 120 121 |
# File 'lib/RubyUnit/Assertions/Comparisons.rb', line 119 def assertLessThanOrEqual less, value, = nil __assert (less <= value), ASSERT_LESSTHANOREQUAL_ERROR, , {:less=>less, :value=>value} end |
#assertMatch(pattern, value, message = nil) ⇒ Object
Assert that a value matches a Regexp pattern.
-
raises RubyUnit::AssertionFailure unless value matches pattern
- pattern
-
A Regexp pattern expected by the assertion
- value
-
The value that is being checked for the assertion
- message
-
The message provided to be reported for a failure
assertMatch /^Hello/, 'Goodbye!', "This will fail" # => fail
138 139 140 141 142 143 |
# File 'lib/RubyUnit/Assertions/Comparisons.rb', line 138 def assertMatch pattern, value, = nil pattern = [pattern] unless pattern.is_a? Array pattern.each do |regex| __assert (value =~ regex), ASSERT_MATCH_ERROR, , {:pattern=>pattern, :value=>value} end end |
#assertNotEqual(illegal, actual, message = nil) ⇒ Object
Assert that two values are NOT equal.
-
raises RubyUnit::AssertionFailure if illegal equals actual
- illegal
-
The value that is not allowed by the assertion
- actual
-
The value that is being checked by the assertion
- message
-
The message provided to be reported for a failure
assertNotEqual 3.14, 3.14, "This will fail" # => fail
43 44 45 |
# File 'lib/RubyUnit/Assertions/Comparisons.rb', line 43 def assertNotEqual illegal, actual, = nil __reject (illegal == actual), ASSERT_NOT_EQUAL_ERROR, , {:illegal=>illegal, :actual=>actual} end |
#assertNotMatch(exclusion, value, message = nil) ⇒ Object
Assert that a value does not match a Regexp pattern.
-
raises RubyUnit::AssertionFailure if value matches pattern
- pattern
-
A Regexp pattern excluded by the assertion
- value
-
The value that is being checked for the assertion
- message
-
The message provided to be reported for a failure
assertMatch /^Good/, 'Goodbye!', "This will fail" # => fail
160 161 162 |
# File 'lib/RubyUnit/Assertions/Comparisons.rb', line 160 def assertNotMatch exclusion, value, = nil __reject (value =~ exclusion), ASSERT_NOT_MATCH_ERROR, , {:exclusion=>exclusion, :value=>value} end |
#assertNotSame(illegal, actual, message = nil) ⇒ Object
Assert that two objects are not the same object
-
raises RubyUnit::AssertionFailure if illegal and actual are the same object.
- illegal
-
The expected that it shouldn’t be
- actual
-
The object that is being checked against illegal
- message
-
The message provided to be reported for a failure
assertNotSame value, value, 'Imagine that!' # => fail
200 201 202 |
# File 'lib/RubyUnit/Assertions/Comparisons.rb', line 200 def assertNotSame illegal, actual, = nil __reject (illegal.equal? actual), ASSERT_NOT_SAME_ERROR, , {:illegal=>illegal, :actual=>actual} end |
#assertSame(expected, actual, message = nil) ⇒ Object
Assert that two objects are the same object
-
raises RubyUnit::AssertionFailure unless expected and actual are the same object.
- expected
-
The expected object
- actual
-
The object that is being checked against expected
- message
-
The message provided to be reported for a failure
assertSame '42', 42, 'Not even close.' # => fail
180 181 182 |
# File 'lib/RubyUnit/Assertions/Comparisons.rb', line 180 def assertSame expected, actual, = nil __assert (expected.equal? actual), ASSERT_SAME_ERROR, , {:expected=>expected, :actual=>actual} end |