A small snippet for testing.
If you want to add some special actions before and after the execution of each test, and don't want to add it to setup and teardown because you will be repeating your code for each unit test and functional test, or because it is a block, you can do an alias_method_chain for the run method:
module Test module Unit class TestCase def run_with_my_block(*args, &block) Cache.clean # code before a_block_that_you_want_to_execute do run_without_my_block(*args, &block) end # Code after end alias_method_chain :run, :my_block end end endIt is not only for Rails but for Ruby. In Rails you can redefine it at the beginning of your test_helper.rb for example.
by Genís