Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

automagic `rake simplecov` task for Rails 3 #83

Merged
merged 1 commit into from

5 participants

@sunaku

This commit defines a Railtie that automatically defines a "simplecov"
Rake task that runs the Rails app's entire test suite under SimpleCov.

The user simply needs to add the following snippet to their Gemfile:

group :development, :test do
  gem 'simplecov'
end

And everything else is taken care of automagically by Rails 3! :sparkles:

@sunaku sunaku automagic `rake simplecov` task for Rails 3
This commit defines a Railtie that automatically defines a "simplecov"
Rake task that runs the Rails app's entire test suite under SimpleCov.
74728ff
@Tekhne

+1

@fgro

+1

@colszowka colszowka merged commit 6c19da4 into from
@colszowka
Owner

Very nice, thanks :)

@sunaku

Finally! :cake:

@colszowka
Owner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 22, 2011
  1. @sunaku

    automagic `rake simplecov` task for Rails 3

    sunaku authored
    This commit defines a Railtie that automatically defines a "simplecov"
    Rake task that runs the Rails app's entire test suite under SimpleCov.
This page is out of date. Refresh to see the latest.
View
3  lib/simplecov.rb
@@ -119,3 +119,6 @@ def usable?
# Load default config
require 'simplecov/defaults'
+
+# Load Rails integration
+require 'simplecov/railtie' if defined? Rails
View
7 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
View
11 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'
Something went wrong with that request. Please try again.