Permalink
Browse files

Add code coverage to build.

  • Loading branch information...
xaviershay committed Dec 24, 2011
1 parent df8a002 commit f8d08e7a8c243517d8df9c822f02988c2a048a99
Showing with 23 additions and 1 deletion.
  1. +1 −0 .gitignore
  2. +6 −0 Gemfile.lock
  3. +1 −1 Rakefile
  4. +1 −0 cane.gemspec
  5. +14 −0 spec/spec_helper.rb
View
@@ -0,0 +1 @@
+coverage
View
@@ -8,6 +8,7 @@ GEM
remote: http://rubygems.org/
specs:
diff-lcs (1.1.3)
+ multi_json (1.0.4)
rake (0.9.2.2)
rspec (2.7.0)
rspec-core (~> 2.7.0)
@@ -17,6 +18,10 @@ GEM
rspec-expectations (2.7.0)
diff-lcs (~> 1.1.2)
rspec-mocks (2.7.0)
+ simplecov (0.5.4)
+ multi_json (~> 1.0.3)
+ simplecov-html (~> 0.5.3)
+ simplecov-html (0.5.3)
tailor (0.1.5)
term-ansicolor (>= 1.0.5)
term-ansicolor (1.0.7)
@@ -28,3 +33,4 @@ DEPENDENCIES
cane!
rake
rspec (~> 2.0)
+ simplecov
View
@@ -13,7 +13,7 @@ end
desc "Run cane to check quality metrics"
task :quality do
- puts `bin/cane --abc-max 10`
+ puts `bin/cane --abc-max 10 --gte coverage/covered_percent,95`
exit $?.exitstatus unless $?.exitstatus == 0
end
View
@@ -29,4 +29,5 @@ Gem::Specification.new do |gem|
gem.add_dependency 'tailor'
gem.add_development_dependency 'rspec', '~> 2.0'
gem.add_development_dependency 'rake'
+ gem.add_development_dependency 'simplecov'
end
View
@@ -6,3 +6,17 @@ def make_file(content)
tempfile.flush
tempfile.path
end
+
+require 'simplecov'
+
+class SimpleCov::Formatter::QualityFormatter
+ def format(result)
+ SimpleCov::Formatter::HTMLFormatter.new.format(result)
+ File.open("coverage/covered_percent", "w") do |f|
+ f.puts result.source_files.covered_percent.to_i
+ end
+ end
+end
+
+SimpleCov.formatter = SimpleCov::Formatter::QualityFormatter
+SimpleCov.start

0 comments on commit f8d08e7

Please sign in to comment.