define() public

No documentation

This method has no description. You can help the RSpec community by adding new notes.

Hide source
# File lib/spec/rake/verify_rcov.rb, line 35
    def define
      desc "Verify that rcov coverage is at least #{threshold}%"
      task @name do
        total_coverage = 0

        File.open(index_html).each_line do |line|
          if line =~ /<tt class='coverage_total'>\s*(\d+\.\d+)%\s*<\/tt>/
            total_coverage = $1.to_f
            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
Register or log in to add new notes.