Permalink
Browse files

Fail the build if test coverage is too low.

  • Loading branch information...
1 parent 55accc4 commit bd3dc79279ff76e63c687d71801e94313735a2fd @myronmarston committed Jan 28, 2012
Showing with 18 additions and 1 deletion.
  1. +11 −1 Rakefile
  2. +7 −0 spec/spec_helper.rb
View
@@ -34,6 +34,16 @@ task :yard_coverage do
end
end
+desc "Checks the spec coverage and fails if it is less than 100%"
+task :check_code_coverage do
+ percent = File.read("./coverage/coverage_percent.txt").to_f
+ if percent < 99.0
+ raise "Spec coverage was not high enough: #{percent.round(2)}%"
+ else
+ puts "Nice job! Spec coverage is still above 99%"
+ end
+end
+
namespace :ci do
desc "Sets things up for a ci build on travis-ci.org"
task :setup do
@@ -52,7 +62,7 @@ namespace :ci do
end
desc "Run a ci build"
- task :build => [:setup, :spec, :cucumber, :yard_coverage]
+ task :build => [:setup, :spec, :cucumber, :yard_coverage, :check_code_coverage]
end
def ensure_relish_doc_symlinked(filename)
View
@@ -10,6 +10,13 @@
add_filter "internet_connection"
end
+SimpleCov.at_exit do
+ File.open(File.join(SimpleCov.coverage_path, 'coverage_percent.txt'), 'w') do |f|
+ f.write SimpleCov.result.covered_percent
+ end
+ SimpleCov.result.format!
+end
+
using_git = File.exist?(File.expand_path('../../.git/', __FILE__))
if using_git
require 'bundler'

0 comments on commit bd3dc79

Please sign in to comment.