class RCov::VerifyTask
running Spec::Rake::SpecTask.
drop below a certain threshold. It should be run after
A task that can verify that the RCov coverage doesn’t
def define
def define desc "Verify that rcov coverage is at least #{threshold}%" task @name do total_coverage = nil File.open(index_html).each_line do |line| if line =~ /<tt class='coverage_total'>(\d+\.\d+)%<\/tt>/ total_coverage = eval($1) break end end puts "Coverage: #{total_coverage}% (threshold: #{threshold}%)" if verbose raise "Coverage must be at least #{threshold}% but was #{total_coverage}%" if total_coverage < threshold raise "Coverage has increased above the threshold of #{threshold}% to #{total_coverage}%. You should update your threshold value." if (total_coverage > threshold) and require_exact_threshold end end
def initialize(name=:verify_rcov)
def initialize(name=:verify_rcov) @name = name @index_html = 'coverage/index.html' @verbose = true @require_exact_threshold = true yield self if block_given? raise "Threshold must be set" if @threshold.nil? define end