Fixed rcov exclude options.
[arvados.git] / tasks / spec.rake
index 77dea59d7a34cb61138f6a36c71b15f15a3fa825..b83d31692293121a189b1c03f6bbc4c0e36e01d0 100644 (file)
@@ -5,14 +5,25 @@ namespace :spec do
     t.spec_files = FileList['spec/**/*_spec.rb']
     t.spec_opts = ['--require', 'rubygems', '--color', '--format', 'specdoc']
     if RCOV_ENABLED
+      if `which rcov`.strip == ""
+        STDERR.puts(
+          "Please install rcov and ensure that its binary is in the PATH:"
+        )
+        STDERR.puts("sudo gem install rcov")
+        exit(1)
+      end
       t.rcov = true
     else
       t.rcov = false
     end
     t.rcov_opts = [
+      '--exclude', 'lib\\/compat',
       '--exclude', 'spec',
+      '--exclude', '\\.rvm\\/gems',
       '--exclude', '1\\.8\\/gems',
-      '--exclude', '1\\.9\\/gems'
+      '--exclude', '1\\.9\\/gems',
+      '--exclude', '\\.rvm',
+      '--exclude', '\\/Library\\/Ruby',
     ]
   end
 
@@ -39,7 +50,7 @@ namespace :spec do
     task :verify => :rcov
   end
 
-  desc "Generate HTML Specdocs for all specs"
+  desc 'Generate HTML Specdocs for all specs'
   Spec::Rake::SpecTask.new(:specdoc) do |t|
     specdoc_path = File.expand_path(
       File.join(File.dirname(__FILE__), '../specdoc/'))
@@ -47,25 +58,25 @@ namespace :spec do
 
     output_file = File.join(specdoc_path, 'index.html')
     t.spec_files = FileList['spec/**/*_spec.rb']
-    t.spec_opts = ["--format", "\"html:#{output_file}\"", "--diff"]
+    t.spec_opts = ['--format', "\"html:#{output_file}\"", '--diff']
     t.fail_on_error = false
   end
 
   namespace :rcov do
-    desc "Browse the code coverage report."
-    task :browse => "spec:rcov" do
-      require "launchy"
-      Launchy::Browser.run("coverage/index.html")
+    desc 'Browse the code coverage report.'
+    task :browse => 'spec:rcov' do
+      require 'launchy'
+      Launchy::Browser.run('coverage/index.html')
     end
   end
 end
 
 if RCOV_ENABLED
-  desc "Alias to spec:verify"
-  task "spec" => "spec:verify"
+  desc 'Alias to spec:verify'
+  task 'spec' => 'spec:verify'
 else
-  desc "Alias to spec:all"
-  task "spec" => "spec:all"
+  desc 'Alias to spec:all'
+  task 'spec' => 'spec:all'
 end
 
-task "clobber" => ["spec:clobber_rcov"]
+task 'clobber' => ['spec:clobber_rcov']