There are a few bits of code I use a lot that resolve headaches - thus analgesic code. I'll be posting these every so often in between pictures of cats and all that.
When I'm building a Ruby on Rails project I often run 'rake test_units', 'rake test_functional', or just plain 'rake' (which does both) to run whole categories of tests. Sometimes it's hard to see where the problems actually come up, since the Ruby on Rails test framework just writes out little '.'s to show progress and then dumps all of the errors at the end.
To solve this, I just add this method to the /test/test_helper.rb file as part of the root TestCase class:
# this is called for each class test so we can easily tell where the tests are running def test_class_name_display puts "Test: " << self.class.name end
Since it has 'test_' at the start of the method name, this runs for every descendent test, and since it's in the parent class, it runs before the rest of the tests.
Wow, I feel better already.