# RCov with Rails

**URL:** <https://www.ruby-forum.com/t/rcov-with-rails/180055>\
**Category:** Rails\
**Created:** [December 10, 2009, 1:52pm UTC](https://www.ruby-forum.com/t/rcov-with-rails/180055 "2009-12-10T13:52:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![shakor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/bcef8e/32.png) [@shakor](https://www.ruby-forum.com/u/shakor)\
**Post date:** [December 10, 2009, 1:52pm UTC](https://www.ruby-forum.com/t/rcov-with-rails/180055/1 "2009-12-10T13:52:46Z")

</div>

I installed the rcov gem and it installed just fine but when I try and  
run:

rcov test/unit/\*.rb

I get:

No file to analyze was found. All the files loaded by rcov matched one  
of the  
following expressions, and were thus ignored:  
[/\A/usr/lib/,  
/\btc\_[^.]\*.rb/,  
/\_test.rb\z/,  
/\btest//,  
/\bvendor//,  
/\A/usr/lib/ruby/gems/1.8/gems/rcov-0.9.6/lib/rcov/formatters/base\_formatter.rb\z/]

You can solve this by doing one or more of the following:

- rename the files not to be ignored so they don’t match the above  
regexps
- use --include-file to give a list of patterns for files not to be  
ignored
- use --exclude-only to give the new list of regexps to match against
- structure your code as follows:  
test/test\__.rb for the test cases  
lib/\*\*/_.rb for the target source code whose coverage you want  
making sure that the test/test\__.rb files are loading from lib/, e.g.  
by  
using the -Ilib command-line argument, adding  
$:.unshift File.join(File.dirname( **FILE** ), “…”, “lib”)  
to test/test\__.rb, or running rcov via a Rakefile (read the RDoc  
documentation or README.rake in the source distribution).  
/usr/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:31:in  
`gem_original_require': no such file to load -- test_helper (LoadError) from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require’  
from ./test/unit/classified\_resource\_test.rb:1  
from /usr/lib/ruby/gems/1.8/gems/rcov-0.9.6/bin/rcov:508:in  
`load' from /usr/lib/ruby/gems/1.8/gems/rcov-0.9.6/bin/rcov:508 from /usr/bin/rcov:19:in `load’  
from /usr/bin/rcov:19

Same thing if I try to run it on a specified unit test.

I thought it should work on rails out of the box but apparently not.

Anyone know what else you need to do? Their web  
([eigenclass.org](http://eigenclass.org/hiki.rb?rcov)) page has no info regarding the  
matter.

---

<div class="post-metadata">

**Author:** ![shakor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/bcef8e/32.png) [@shakor](https://www.ruby-forum.com/u/shakor)\
**Post date:** [December 10, 2009, 2:35pm UTC](https://www.ruby-forum.com/t/rcov-with-rails/180055/2 "2009-12-10T14:35:12Z")

</div>

Problem solved. Apparently you need to be in the app test folder and not  
the rails app root folder then you run the command.
