| Module | Test::Unit::Assertions |
| In: |
lib/test/unit/assertions.rb
|
Test::Unit::Assertions contains the standard Test::Unit assertions. Assertions is included in Test::Unit::TestCase.
To include it in your own code and use its functionality, you simply need to rescue Test::Unit::AssertionFailedError. Additionally you may override add_assertion to get notified whenever an assertion is made.
Notes:
def deny(boolean, message = nil)
message = build_message message, '<?> is not false or nil.', boolean
assert_block message do
not boolean
end
end
| UncaughtThrow | = | {NameError => /^uncaught throw \`(.+)\'$/, ThreadError => /^uncaught throw \`(.+)\' in thread /} |
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.
The assertion upon which all other assertions are based. Passes if the block yields true.
Example:
assert_block "Couldn't do the thing" do
do_the_thing
end
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.
Example:
assert_equal 'MY STRING', 'my string'.upcase
Passes if expected_float and actual_float are equal within delta tolerance.
Example:
assert_in_delta 0.05, (50000.0 / 10**6), 0.00001
Compares the +object1+ with +object2+ using operator.
Passes if object1.send(operator, object2) is true.
Example:
assert_operator 5, :>=, 4
Passes if the block raises one of the given exceptions.
Example:
assert_raise RuntimeError, LoadError do
raise 'Boom!!!'
end
Passes if actual .equal? expected (i.e. they are the same instance).
Example:
o = Object.new assert_same o, o
Passes if the method send returns a true value.
send_array is composed of:
Example:
assert_send [[1, 2], :include?, 4]
ruby-doc.org is hosted and maintained by James Britt and Happy Camper Studios, a Ruby application development company in Phoenix, Arizona. The site was created in 2002 as part of the Ruby Documentation Project to promote the Ruby language and to help other Ruby hackers.
Documentation content on ruby-doc.org is provided by remarkable members of the Ruby community.
For more information on the Ruby programming language, visit ruby-lang.org.
Want to help improve Ruby's API docs? See Ruby Documentation Guidelines.