News and Blog

How to run Rcov in the Ruby on Rails vendor directory

March 5th, 2009 » No Comments »

Originally posted at: http://buzaz.com/index.php/2009/03/05/run-rcov-in-the-vendor-directory/

We 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.

Leave a Reply

What People are Saying

"We love working with Integrum — they always get excited about new projects and changes we want to make to the site, and their enthusiasm for web design and development really shows. They’re also great at explaining things in “layman’s terms” for those of us who aren’t so tech-savvy."

— Jackie, www.rattlebox.com

Announcements

MountainWest RubyConf 2009

We’re sponsoring this years MountainWest RubyConf, March 13-14. Are you going? You should be there – we will be! For more information visit http://mtnwestrubyconf.org/2009/.

Gangplank Hacknight

What is Hacknight? The best way to find out is show up. It is whatever we make it.

Gangplank Academy

Come to Gangplank, same address as Integrum, each Wednesday at 11:45 a.m. for brown bag lunch and a presentation.

Calling all Rails Nerds!

We want you (to work for us)! Drop us a line at hr@integrumtech.com.


Press Room

Where We’re At:

  1. Hacknight Every Wed.
  2. Gangplank Academy Brownbag Wednesdays
  3. SXSW Mar 12th-17th
  4. Mountain West Ruby ConfMar 11th-12th

Updates