Flunking a test
When I write unit tests in Java, I sometimes want to assert a fail to force the test to fail. Generally because this is because I’m testing something that hasn’t been thought about yet and I want to leave myself a nagging note to do something about it… In Java I’d do something like:
assert(false);
test/unit, the testing library used by Rails, has a really lovely named method: ‘flunk’ – for when you just want to flunk and test and cause a fail:
flunk ( [msg] )
One of the nicest things about Rails and ‘convention over configuration’ is that things are named well. After all, there are only two great problems in computer science; cache invalidation and naming things!