Skip to content

Instantly share code, notes, and snippets.

@dnagir
Created January 28, 2012 07:24
Show Gist options
  • Save dnagir/1693201 to your computer and use it in GitHub Desktop.
Save dnagir/1693201 to your computer and use it in GitHub Desktop.
Fail CI build with SimpleCov
# 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