Skip to content

Instantly share code, notes, and snippets.

@ahawkins
Created September 9, 2010 19:20
Show Gist options
  • Save ahawkins/572379 to your computer and use it in GitHub Desktop.
Save ahawkins/572379 to your computer and use it in GitHub Desktop.
[:models, :controllers, :views, :helpers, :lib, :mailers, :observers, :middleware].each do |sub|
desc "Run #{sub} specs with rcov"
Spec::Rake::SpecTask.new("rcov:#{sub}" => spec_prereq) do |t|
t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]
t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"]
t.rcov = true
# create exclusion patterns since there no "inlucde only" option with rspec
directories = [:models, :controllers, :views, :helpers, :lib, :mailers, :observers, :middleware].reject {|dir| dir == sub}
patterns = directories.map {|dir| "\"#{dir}/*\""}
defaults = ['"spec/*"', '"gems/*"']
excludes = "--exclude " + (patterns + defaults).join(',')
t.rcov_opts = [excludes, '--rails']
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment