How to run Rcov in the Ruby on Rails vendor directory
5 March 2009 in Ruby on RailsWe have a long-term project at Integrum which stores rails apps as extensions in the vendor directory. For the longest time we have not been able to get test coverage stats on these extensions. When we ran rcov it would run our specs - but when we opened the index.html file in the coverage folder, none of our extension code had been analyzed.
It turns out that rcov by default ignores the vendor directory - which makes sense generally. So it turns out you have to be explicit when you want to run rcov on anything in the folder:
Spec::Rake::SpecTask.new(:rcov) do |task|
task.rcov = args[:rcov]
task.spec_opts = @spec_opts
extension_path = "vendor/other_extensions/#{ENV['EXTENSION']}"
task.spec_files = ["#{extension_path}/spec/**/*_spec.rb"]
task.rcov_opts = ["--include-file #{extension_path}/",
'--exclude app,config,lib,spec']
end
The important thing here is
task.rcov_opts = [”–include-file . . .
This line lets Rcov know to run stats on that folder, even though it is part of vendor. Hope that helps.
1 Comment to How to run Rcov in the Ruby on Rails vendor directory
Leave a comment
Tweets
- study: "In 2 years, work perf of high school recruited devs indistinguishable from more experienced peers"(paraphrase)http://tcrn.ch/daXoHA (link)
- Attention Software Developers: We better be rich before we turn 50 http://tcrn.ch/daXoHA :( (link)
- @integrum was mentioned in the devshow podcast #14 for its hiring practice of having developers download a project from Git and re-factor. (link)
- @supairish good point! (link)
- Like the unobtrusive js in Rails 3 but stuck on 2.3.dumb? Just include Rv3 jquery adapter (a .js file) in ur project! http://bit.ly/bqjVGH (link)
- Introducing netrecorder, my first ruby gem.
3 January 2010 - How to build a ruby gem and host it on gemcutter
3 January 2010 - DEMO!
18 December 2009 - It puts the lotion on its skin
14 December 2009 - Cucumber Code Ratio
14 December 2009
- Tobi:
^^ shit, ok now I see it's not your fault, its (my... - Tobi:
Thanks for this great writeup! btw. you missed... - Chris Young:
Thanks for letting me know. I updated the link.... - maxjgon:
The link of the project in Github is broken!... - Chris Young:
Oh I see . . . Maybe I should check out this so-c...
[...] Re-posted on the Integrum Blog [...]