Module: Test::Unit::Assertions
- Defined in:
- lib/s4t-utils/more-assertions.rb
Overview
Some additional Test::Unit assertions.
Instance Method Summary collapse
-
#assert_false(boolean, message = nil) ⇒ Object
Assert that the boolean is false.
-
#assert_raise_with_matching_message(exception_class, message, &block) ⇒ Object
(also: #assert_raises_with_matching_message)
Like
assert_raise
, but the raised exception must contain amessage
matching (as inassert_match
) the message argument. -
#assert_true(boolean, message = nil) ⇒ Object
Same as
assert
. -
#assert_wants_to_exit ⇒ Object
Assert that the block tried to
exit
.
Instance Method Details
#assert_false(boolean, message = nil) ⇒ Object
Assert that the boolean is false.
12 13 14 15 16 |
# File 'lib/s4t-utils/more-assertions.rb', line 12 def assert_false(boolean, = nil) _wrap_assertion do assert_block((, "<?> should be false or nil.", boolean)) { !boolean } end end |
#assert_raise_with_matching_message(exception_class, message, &block) ⇒ Object Also known as: assert_raises_with_matching_message
Like assert_raise
, but the raised exception must contain a message
matching (as in assert_match
) the message argument.
20 21 22 23 |
# File 'lib/s4t-utils/more-assertions.rb', line 20 def (exception_class, , &block) exception = assert_raise(exception_class, &block) assert_match(, exception.) end |
#assert_true(boolean, message = nil) ⇒ Object
Same as assert
. I just like it better.
7 8 9 |
# File 'lib/s4t-utils/more-assertions.rb', line 7 def assert_true(boolean, = nil) assert(boolean, ) end |
#assert_wants_to_exit ⇒ Object
Assert that the block tried to exit
.
28 29 30 31 32 |
# File 'lib/s4t-utils/more-assertions.rb', line 28 def assert_wants_to_exit assert_raise(SystemExit) do yield end end |