assert{ 2.0 }

This library obsoletes the following RubyUnit assertions:
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_nil(x) becomes deny{ x }.
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, like this:

__source__ __failure_diagnostic__
x = 43
assert{ x == 42 }
assert{ x == 42 } --> false - should pass
    x --> 43
deny{ x == 43 }
deny{ x == 43 } --> true - should not pass
    x --> 43

See the assert{ 2.0 } blog to learn more about the philosophy behind this "nice Ruby hack".

To add even more information, pass a diagnostic message to either assert{} or deny{}:

  assert("my colleague made me do this"){ foo() == 42 }

Installation

Get assert{ 2.0 } the usual way:
  gem install assert2
It will require the crucial & conscious RubyNode library, by Dominik Bathon.

Then add these lines to your test suites:

  require 'rubygems'
  require 'assert2'
Send any suggestions to phlip2000@gmail.com!