Ruby Test::Unit::Assertions Functions

EditRocket provides the following information on Test::Unit::Assertions functions in the Ruby source code builder.

assert(boolean, message=nil) - Asserts that boolean is not false or nil.

assert_block(message="assert_block failed.") - The assertion upon which all other assertions are based. Passes if the block yields true.

assert_equal(expected, actual, message=nil) - Passes if expected == +actual.

assert_in_delta(expected_float, actual_float, delta, message="") - Passes if expected_float and actual_float are equal within delta tolerance.

assert_instance_of(klass, object, message="") - Passes if object .instance_of? klass

assert_kind_of(klass, object, message="") - Passes if object .kind_of? klass

assert_match(pattern, string, message="") - Passes if string =~ pattern.

assert_nil(object, message="") - Passes if object is nil.

assert_no_match(regexp, string, message="") - Passes if regexp !~ string

assert_not_equal(expected, actual, message="") - Passes if expected != actual

assert_not_nil(object, message="") - Passes if ! object .nil?

assert_not_same(expected, actual, message="") - Passes if ! actual .equal? expected

assert_nothing_raised(*args) - Passes if block does not raise an exception.

assert_nothing_thrown(message="", &proc) - Passes if block does not throw anything.

assert_operator(object1, operator, object2, message="") - Compares the +object1+ with +object2+ using operator.

assert_raise(*args) - Passes if the block raises one of the given exceptions.

assert_raises(*args, &block) - Alias of assert_raise.

assert_respond_to(object, method, message="") - Passes if object .respond_to? method

assert_same(expected, actual, message="") - Passes if actual .equal? expected (i.e. they are the same instance).

assert_send(send_array, message="") - Passes if the method send returns a true value.

assert_throws(expected_symbol, message="", &proc) - Passes if the block throws expected_symbol

build_message(head, template=nil, *arguments) - Builds a failure message. head is added before the template and arguments replaces the '?'s positionally in the template.

flunk(message="Flunked") - Flunk always fails.

use_pp=(value) - Select whether or not to use the pretty-printer. If this option is set to false before any assertions are made, pp.rb will not be required.