Code coverage of a rails plugin


I’ve been struggling with this one for a couple of hours, and nothing
seems to work here, any advice would be duly appreciated…

Background: I’m busy working on a plugin called “shared_models”,
allowing you to easily share models between different applications,
running different database or on the same database. The plugin is
nearly complete, offering a generator that generates models, unit
tests, fixtures and even migrations. Some other goodies included too,
but you’ll have to wait for the release :slight_smile:

Problem: I’m trying to add a rake task that will generate coverage
information for the shared_models, but I can’t get this to work
properly. rcov keeps on spitting out coverage information for the
application housing the plugin.

require ‘rcov/rcovtask’

namespace :shared_models do
namespace :test do do |t|
t.libs << “#{File.dirname(FILE)}/…/test”
t.test_files = FileList[“#{File.dirname(FILE)}/…/test/*.rb”,

t.output_dir = “#{File.dirname(FILE)}/…/test/coverage”
t.verbose = true

rcov is running, and from the debug output I can see that the correct
files are loaded inside the plugins’ test, and test/unit directories.
Below is the output from running the task:

rm -r ./vendor/plugins/shared_models/tasks/…/test/coverage
/usr/bin/ruby18 -Ilib:./vendor/plugins/shared_models/tasks/…/test -S
rcov --text-report -o
Loaded suite /usr/bin/rcov

Finished in 0.023935 seconds.

2 tests, 2 assertions, 0 failures, 0 errors
| File | Lines | LOC | COV |
|app/controllers/application.rb | 6 | 3 | 100.0% |
|app/helpers/application_helper.rb | 15 | 11 | 27.3% |
|config/boot.rb | 44 | 35 | 62.9% |
|config/environment.rb | 53 | 4 | 100.0% |
|config/routes.rb | 22 | 5 | 100.0% |
|Total | 140 | 58 | 63.8% |
63.8% 5 file(s) 140 Lines 58 LOC

</rake shared_models:test:coverage>

So, the task does clobber (and output to) the correct directory, but
contains no coverage information for any of the code in the plugin…

This is my last stumbling stone before releasing…

Thanks in advance!

Kenneth K.
[email protected]

Folding@home stats