assert{ 2.0 }

Railsers:

The following RubyUnit assertions are now obsolete:

  assert   assert_block   assert_equal   assert_instance_of   assert_kind_of   assert_operator   assert_match   assert_nil   assert_no_match   assert_not_equal   assert_not_nil

The next time you think to type any of them, use assert{ 2.0 } instead. Put whatever you like inside the { block }. assert_equal(x, y) becomes assert{ x == y }. assert_not_nil(x) becomes ... just assert{ x }! If the last statement in that block fails, your test runner will reflect the name and value of every variable in your assertion. Diagnosing assertion failures has never been easier!

Get assert{ 2.0 } the usual way:

  gem install assert2

Then require 'assert2' into your test suites.

Use deny{} for situations like assert_nil that must fail.

To provide even more commentary, when either assertion fails, pass a string into either assert or deny, like this:

  assert('my colleague made me do this'){ foo() < 42 }

Note: This works "best" with Ruby 1.8.6!

Feedback welcome, and happy testing!