Skip to content
Browse files

allow simplecov's coverage/.last_run.json as coverage measure

  • Loading branch information...
1 parent 6340712 commit cc69b26567928de62d11cdbd73c8e289aba69c08 @pitr pitr committed with xaviershay
Showing with 17 additions and 1 deletion.
  1. +1 −1 lib/cane/threshold_check.rb
  2. +16 −0 spec/threshold_check_spec.rb
View
2 lib/cane/threshold_check.rb
@@ -47,7 +47,7 @@ def normalized_limit(limit)
def value_from_file(file)
begin
- contents = Cane::File.contents(file).chomp.to_f
+ contents = Cane::File.contents(file).scan(/\d+\.?\d*/).first.to_f
rescue Errno::ENOENT
UnavailableValue.new
end
View
16 spec/threshold_check_spec.rb
@@ -4,6 +4,16 @@
describe Cane::ThresholdCheck do
+ let(:simplecov_last_run) do
+ <<-ENDL
+ {
+ "result": {
+ "covered_percent": 93.88
+ }
+ }
+ ENDL
+ end
+
context "checking violations" do
context "when the current coverage cannot be read" do
@@ -45,6 +55,12 @@
limit = subject.normalized_limit("/File.does.not.exist")
limit.should be_a Cane::ThresholdCheck::UnavailableValue
end
+
+
+ it 'normalizes a json file to a float' do
+ subject.normalized_limit(make_file(simplecov_last_run)).should == 93.88
+ end
+
end
end

0 comments on commit cc69b26

Please sign in to comment.
Something went wrong with that request. Please try again.