From d444f845ef9d92175c6da078c1843be3d457c670 Mon Sep 17 00:00:00 2001 From: Jesse Scott Date: Tue, 6 Nov 2012 14:17:19 -0800 Subject: [PATCH] Made sure SourceFile.covered_percent and FileList.covered_strength won't return Rationals even when 'mathn' has been included. --- lib/simplecov/file_list.rb | 2 +- lib/simplecov/source_file.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/simplecov/file_list.rb b/lib/simplecov/file_list.rb index 549070ba..21b3d75c 100644 --- a/lib/simplecov/file_list.rb +++ b/lib/simplecov/file_list.rb @@ -39,6 +39,6 @@ def covered_percent # Computes the strength (hits / line) based upon lines covered and lines missed def covered_strength return 0 if empty? or lines_of_code == 0 - map {|f| f.covered_strength }.inject(&:+) / size + map {|f| f.covered_strength }.inject(&:+).to_f / size end end diff --git a/lib/simplecov/source_file.rb b/lib/simplecov/source_file.rb index deb1998d..73d90cc7 100644 --- a/lib/simplecov/source_file.rb +++ b/lib/simplecov/source_file.rb @@ -114,7 +114,7 @@ def covered_percent if relevant_lines == 0 0 else - (covered_lines.count) * 100 / relevant_lines.to_f + (covered_lines.count) * 100.0 / relevant_lines.to_f end end