Created
January 28, 2012 07:24
-
-
Save dnagir/1693201 to your computer and use it in GitHub Desktop.
Fail CI build with SimpleCov
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# lib/tasks/ci.rake | |
require 'nokogiri' | |
desc "Run everything on the CI server with all its outcomes (deploy etc)" | |
task :ci do | |
Rake::Task['spec'].invoke | |
ensure_test_coverage 99 | |
Rake::Task['cucumber'].invoke | |
# TODO: Figure out how to run Jasminerice https://github.com/bradphelan/jasminerice/issues/31 | |
end | |
def ensure_test_coverage(threshold) | |
doc = Nokogiri::HTML File.read("coverage/index.html") | |
node = doc.css("h2:first .covered_percent").first | |
covered = node.content.to_f | |
raise "The test coverage #{covered}% is below the threshold of #{threshold}%. Not good enough, sorry." if covered < threshold | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment