Skip to content

Commit

Permalink
automagic rake simplecov task for Rails 3
Browse files Browse the repository at this point in the history
This commit defines a Railtie that automatically defines a "simplecov"
Rake task that runs the Rails app's entire test suite under SimpleCov.
  • Loading branch information
sunaku committed Sep 22, 2011
1 parent db9d374 commit 74728ff
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/simplecov.rb
Expand Up @@ -119,3 +119,6 @@ def usable?

# Load default config
require 'simplecov/defaults'

# Load Rails integration
require 'simplecov/railtie' if defined? Rails
7 changes: 7 additions & 0 deletions lib/simplecov/railtie.rb
@@ -0,0 +1,7 @@
module SimpleCov
class Railtie < ::Rails::Railtie
rake_tasks do
load 'simplecov/railties/tasks.rake'
end
end
end
11 changes: 11 additions & 0 deletions lib/simplecov/railties/tasks.rake
@@ -0,0 +1,11 @@
require 'rake/testtask'
Rake::TestTask.new do |t|
t.name = 'simplecov'
t.loader = :direct # uses require() which skips PWD in Ruby 1.9
t.libs.push 'test', 'spec', Dir.pwd
t.test_files = FileList['{test,spec}/**/*_{test,spec}.rb']
t.ruby_opts.push '-r', 'simplecov', '-e', 'SimpleCov.start(:rails)'.inspect
end

require 'rake/clean'
CLOBBER.include 'coverage'

0 comments on commit 74728ff

Please sign in to comment.