Module Test::Unit::Assertions
In: 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().

Methods

Classes and Modules

Class Test::Unit::Assertions::AssertionMessage

Constants

UncaughtThrow = {NameError => /^uncaught throw \`(.+)\'$/, ThreadError => /^uncaught throw \`(.+)\' in thread /}

Public Class methods

Select whether or not to use the prettyprinter. If this option is set to false before any assertions are made, the prettyprinter will not be required at all.

Public Instance methods

Passes if boolean is true.

The assertion upon which all other assertions are based. Passes if the block yields 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 expected_float and actual_float are equal within delta tolerance.

Passes if object.class == klass.

Passes if object.kind_of?(klass).

Passes if string =~ pattern.

Passes if object.nil?.

Passes if string !~ regularExpression.

Passes if !object.nil?.

Passes if !actual.equal?(expected).

Passes if block does not raise an exception.

Passes if block does not throw anything.

Compares the two objects based on the passed operator. Passes if object1.send(operator, object2) is true.

Passes if block raises one of the given exceptions.

Alias of assert_raise. Will be deprecated in 1.9, and removed in 2.0.

Passes if object.respond_to?(method) is true.

Passes if actual.equal?(expected) (i.e. they are the same instance).

Passes if the method sent returns a true value.

[Validate]