[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

[ANN] assert_yin_yang

Phlip

5/24/2008 8:24:00 PM

This assertion extends assert{ 2.0 } to wrap this common testing
idiom:

q = method_that_might_return_41()
deny{ q == 42 }
q += method_that_should_return_one()
assert{ q == 42 }

The upgrade is:

q = method_that_might_return_41()
assert_yin_yang proc{ q += method_that_should_return_one() },
proc{ q == 42 }

In exchange for just a little verbosity, the expression q == 42 is now
more DRY.

Further, if q accidentally equals 42 before, or accidentally does not
equal it after the call to q += method_that_should_return_one(), the
assertion reflects the source code (but not the values!) of the
activation block.

Read more at:

http://assert2.rubyforge.org/assert_yin...

and get it with:

sudo gem install assert2

--
Phlip