Module: Test::Unit::Assertions

Defined in:
lib/s4t-utils/more-assertions.rb

Overview

Some additional Test::Unit assertions.

Instance Method Summary collapse

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, 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) ⇒ 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 assert_raise_with_matching_message(exception_class, message, &block)
  exception = assert_raise(exception_class, &block)
  assert_match(message, exception.message)
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, message = nil)
  assert(boolean, message)
end

#assert_wants_to_exitObject

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