Ruby 1.8.7 リファレンスマニュアル > ライブラリ一覧 > test/unit/assertionsライブラリ > Test::Unit::Assertionsモジュール > assert_block

instance method Test::Unit::Assertions#assert_block

assert_block(message = "assert_block failed.") { ... } -> ()

ブロックを実行し、その結果が真ならパスします。

新しい assert メソッドを定義する時にも使います。

def deny(boolean, message = nil)
  message = build_message message, '<?> is not false or nil.', boolean
  assert_block message do
    not boolean
  end
end
[PARAM] message:
assert が失敗した時に表示するメッセージを文字列で指定し ます。指定しなかった場合は表示しません。
[EXCEPTION] Test::Unit::AssertionFailedError:
assert が失敗した時に発生します。
module Test::Unit::Assertions