Created
December 20, 2013 17:32
-
-
Save aghyad/8058396 to your computer and use it in GitHub Desktop.
My take on testing rake tasks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
So you like to write some complicated tests plugged into your rake tasks. Or may be you think you're doing a crime not doing so. I understand. Nothing is wrong with that. But it's more like buying a helicopter so you can travel two blocks in Manhattan. | |
I'll explain: | |
1 - Rake tasks are not meant to be a complicated piece of your website. Instead, rake tasks are meant to be "thin" and only to invoke other modules in your system. Those modules do the heavy work. Those modules are what really matters. So, test the meaningful code and not the code that invokes it. Well, if you are still feeling unconfident about the invoking processes ... then: | |
2 - Trust rails and trust the whole framework. Don't bother testing whether this rake task is going to print something minor. It will work. Otherwise, you have a bigger issue that missing tests in the framework. | |
In summary: Focus your energy more on testing the functionality that this rake task is written to invoke, which is a class or a method some where else in your models or lib files or any where else. | |
Otherwise, your website will start killing kittens and choking birds for no reason! - not that there's a reason anyway to kill or choke kittens and birds :) | |
Don't be mad - I'm just sayin' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment