A task that can verify that the RCov coverage doesn’t drop below a certain threshold. It should be run after running Spec::Rake::SpecTask.
Path to the index.html file generated by RCov, which is the file containing the total coverage. Defaults to ‘coverage/index.html‘
# File lib/spec/rake/verify_rcov.rb, line 25
25: def initialize(name=:verify_rcov)
26: @name = name
27: @index_html = 'coverage/index.html'
28: @verbose = true
29: @require_exact_threshold = true
30: yield self if block_given?
31: raise "Threshold must be set" if @threshold.nil?
32: define
33: end
# File lib/spec/rake/verify_rcov.rb, line 35
35: def define
36: desc "Verify that rcov coverage is at least #{threshold}%"
37: task @name do
38: total_coverage = 0
39:
40: File.open(index_html).each_line do |line|
41: if line =~ /<tt class='coverage_total'>\s*(\d+\.\d+)%\s*<\/tt>/
42: total_coverage = $1.to_f
43: break
44: end
45: end
46: puts "Coverage: #{total_coverage}% (threshold: #{threshold}%)" if verbose
47: raise "Coverage must be at least #{threshold}% but was #{total_coverage}%" if total_coverage < threshold
48: 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
49: end
50: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.