module Test::Unit::Assertions

Some additional Test::Unit assertions.

Public Instance Methods

assert_false(boolean, message = nil) click to toggle source

Assert that the boolean is false.

# File lib/s4t-utils/more-assertions.rb, line 12
def assert_false(boolean, message = nil)
  _wrap_assertion do
    assert_block(build_message(message, "<?> should be false or nil.", boolean)) { !boolean }
  end
end
assert_raise_with_matching_message(exception_class, message, &block) click to toggle source

Like assert_raise, but the raised exception must contain a message matching (as in assert_match) the message argument.

# File lib/s4t-utils/more-assertions.rb, line 20
def assert_raise_with_matching_message(exception_class, message, &block)
  exception = assert_raise(exception_class, &block)
  assert_match(message, exception.message)
end
assert_raises_with_matching_message(exception_class, message, &block) click to toggle source
assert_true(boolean, message = nil) click to toggle source

Same as assert. I just like it better.

# File lib/s4t-utils/more-assertions.rb, line 7
def assert_true(boolean, message = nil)
  assert(boolean, message)
end
assert_wants_to_exit() { || ... } click to toggle source

Assert that the block tried to exit.

# File lib/s4t-utils/more-assertions.rb, line 28
def assert_wants_to_exit
  assert_raise(SystemExit) do
    yield
  end
end