Thus, unit testing is indeed not supported by assets. Ruby comes with a typical xunit framework in standard libs (Test :: Unit in ruby 1.8.x, MiniTest in ruby 1.9), and the stuff in activesupport just adds a few things to it.
If you use Test :: Unit / MiniTest
assert_raises(Exception) { whatever.merge }
if you use rspec (unfortunately poorly documented, but more popular)
lambda { whatever.merge }.should raise_error
If you want to check the raised Exception :
exception = assert_raises(Exception) { whatever.merge } assert_equal( "message", exception.message )
Matt Briggs Aug 11 '10 at 2:54
source share