Permalink
Browse files

SHOW_ONLY feature copied from the original rails_rcov plugin, see ht…

…tp://svn.codahale.com/rails_rcov

Signed-off-by: commondream <alan@gnoso.com>
  • Loading branch information...
dovadi authored and commondream committed Feb 12, 2009
1 parent 3e932f1 commit c92c0612374d7e15209b1604a08246f490c5f814
Showing with 38 additions and 0 deletions.
  1. +15 −0 README.markdown
  2. +23 −0 tasks/rcov.rake
View
@@ -10,6 +10,21 @@ This is a simple rails plugin that adds some useful rcov tasks.
The task ends up creating a coverage folder with an html coverage report in it.
SHOW_ONLY is a comma-separated list of the files you'd like to see (although
you can only run functionals, you still see all the models and helpers which
are 'touched'). Right now there are four types of files rake test:coverage
recognizes: models, helpers, controllers, and lib. These can be abbreviated
to their first letters:
# only show files from app/models
rake test:coverage SHOW_ONLY=models
# only show files from app/helpers and app/controllers
rake test:coverage SHOW_ONLY=helpers,controllers
# only show files from app/helpers and app/controllers, with less typing
rake test:coverage SHOW_ONLY=h,c
Requirements
============
View
@@ -15,6 +15,29 @@ def run_coverage(files)
else
exclude = '--exclude "rubygems/*"'
end
# rake test:units:rcov SHOW_ONLY=models,controllers,lib,helpers
# rake test:units:rcov SHOW_ONLY=m,c,l,h
if ENV['SHOW_ONLY']
params = String.new
show_only = ENV['SHOW_ONLY'].to_s.split(',').map{|x|x.strip}
if show_only.any?
reg_exp = []
for show_type in show_only
reg_exp << case show_type
when 'm', 'models' : 'app\/models'
when 'c', 'controllers' : 'app\/controllers'
when 'h', 'helpers' : 'app\/helpers'
when 'l', 'lib' : 'lib'
else
show_type
end
end
reg_exp.map!{ |m| "(#{m})" }
params << " --exclude \"^(?!#{reg_exp.join('|')})\""
end
exclude = exclude + params
end
rcov = "rcov --rails -Ilib:test --sort coverage --text-report #{exclude} --no-validator-links"
puts

0 comments on commit c92c061

Please sign in to comment.