[rspec-users] Rake features:rcov question

Matt Wynne matt at mattwynne.net
Mon Jan 19 15:38:16 EST 2009

On 19 Jan 2009, at 15:49, James Byrne wrote:

> I have reached a point where I thought that it might be useful to see
> how must test coverage I have for the code I have written.  However,
> running rake features:rcov produces some unexpected output.  I see  
> this
> in the index file:
> /usr/lib/ruby/1.8/base64.rb ...
> /usr/lib/ruby/1.8/benchmark.rb ...
> ...
> /usr/lib/ruby/1.8/uri/mailto.rb
> Then my files are reported
> app/controllers/application_controller.rb
> app/controllers/clients_controller.rb
> ...
> and so forth.  Now, I have checked the spec and test directory trees
> and there does not seem to be anything in there that I recognize as
> having anything to do with the ruby libraries.  My questions are: 1.  
> Is
> this normal behaviour for rcov? 2. If not, then what might I have done
> to cause this?
> Regards,
> -- 
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

Take a look at the --exclude option for rcov - that's what you need to  
do. Otherwise by default it will tell you about coverage for every  
ruby file that was touched during the test run, including things that  
the testing framework called, and the things they called, etc.

I would have assumed this was in the default rake task that was  
generated, but anyway you should be able to figure it out if you look  
at rcov's options.

Running rcov yourself really isn't such a black art - from the command  
line you can get coverage from a single feature using this:

     rcov --exclude 'gems/*.rb' /usr/local/bin/cucumber -- path/to/ 

Matt Wynne

More information about the rspec-users mailing list