Method: Test::Unit::Assertions#assert_raise

Defined in:
lib/test/unit/assertions.rb

#assert_raise(*args, &block) ⇒ Object



141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/test/unit/assertions.rb', line 141

def assert_raise(*args, &block)
  assert_expected_exception = Proc.new do |*_args|
    message, assert_exception_helper, actual_exception = _args
    expected = assert_exception_helper.expected_exceptions
    full_message = build_message(message,
                                 "<?> exception expected but was\n?",
                                 expected, actual_exception)
    assert_block(full_message) do
      expected == [] or assert_exception_helper.expected?(actual_exception)
    end
  end
  _assert_raise(assert_expected_exception, *args, &block)
end