Module Test::Unit::Assertions
|
In: |
test/unit/assertions.rb
|
|
Contains all of the standard Test::Unit assertions. Mixed in to Test::Unit::TestCase. To mix it in and use its
functionality, you simply need to rescue Test::Unit::AssertionFailedError, and
you can additionally override add_assertion to be notified whenever an
assertion is made.
Notes:
- The message to each assertion, if given, will be propagated with the
failure.
- It's easy to add your own assertions based on assert_block().
The assertion upon which all other assertions are based. Passes if the
block yields true.
Passes if boolean is true.
Passes if expected == actual. Note that the ordering of arguments is
important, since a helpful error message is generated when this one fails
that tells you the values of expected and actual.
Passes if block raises exception.
Passes if object.class == klass.
Passes if object.kind_of?(klass).
Passes if object.respond_to?(method) is true.
Passes if string =~ pattern.
Passes if actual.equal?(expected) (i.e. they are the same instance).
Compares the two objects based on the passed operator. Passes if
object1.send(operator, object2) is true.
Passes if block does not raise an exception.
Passes if !actual.equal?(expected).
Passes if expected != actual.
Passes if string !~ regularExpression.
Passes if block throws symbol.
Passes if block does not throw anything.
Passes if expected_float and actual_float are equal within delta tolerance.
Passes if the method sent returns a true value.
Called whenever an assertion is made.