The answer is simple: stop using rake. Odds are you're using rake as a way to run ruby code. Instead create a CLI to do the the thing. This should make you consider how to design, thus how to test it, and thusly create better software. You'll thank me in time.