I recently wanted to run rcov, the Ruby code coverage tool, on a project tested with RSpec. I think I’d done it once before, but I’d forgotten how. After searching to no avail (both the rcov home page and the RSpec page on rcov proved unhelpful), I applied the tried-and-true Wild-Assed Guess™ method and typed
$ rake spec:rcov
That worked.
The reports themselves are in the coverage/ directory:
$ open coverage/index.html
(or navigate your browser to file:///path/to/project/coverage/index.html). If you’re using Git, add coverage/* to your .gitignore file.
N.B. The inverse Rake task also exists:
$ rake -T rcov rake spec:clobber_rcov # Remove rcov products for rcov rake spec:rcov # Run all specs in spec directory with RCov (excluding plugin specs)