After reading @joshclayton’s awesome post about testing Rake tasks (Test Rake Tasks Like a BOSS), I have been using some of the shared context code he wrote to test my own Rake tasks. Usually all my test is doing is verifying that some class I built, like WeatherConditionsFetchTask
, had its #go
method called, and the nitty-gritty of the functionality it tested somewhere else.
I have noticed an unpleasant side-effect of this shared context, however, and I was wondering if Thoughtboters had found a solution: when I run all my specs using Simplecov (or the CodeClimate test coverage tool, which seems to be using Simplecov under the hood), only one of my Rake tests will show up as being covered in the test coverage report, even though when I run RSpec with verbose (-fd flag) spec output, I can clearly see that all the Rake tests are being run. I suspect that somewhere in the subject-setting magic of the shared context the references to the prior tests are getting blown away.
So if any of you use Simplecov, have you had a similar issue, also, since this shared context was written in late 2011, does Thoughtbot use an updated version of this code that is more compatible with test coverage tools?