I’m not sure why overriding rake tasks is so difficult. One gets the feeling that it is frowned upon… but then I’ve found it necessary on more than a few occassions.
Here’s a quick and dirty way to get rid of a task (presumably, right before you redefine it):
Rake.application.send(:eval, "@tasks.delete('db:test:purge')")
In some cases, you can get away with just clearing out the prerequisties - such as overriding the default task. If you’re using RSpec, you probably don’t want to run rake test
prior to running your specs, so this will do the trick:
Rake::Task[:default].prerequisites.clear