Permalink
Browse files

Add simplecov for coverage reports

  • Loading branch information...
1 parent 2985a65 commit 7c6317edb80e005bdfc37dfe73a9daf921a73d47 @harukizaemon harukizaemon committed Mar 7, 2011
Showing with 25 additions and 5 deletions.
  1. +1 −0 .gitignore
  2. +1 −1 Rakefile
  3. +1 −0 hamster.gemspec
  4. +9 −0 spec/spec_helper.rb
  5. +0 −4 tasks/rspec.rb
  6. +13 −0 tasks/spec.rb
View
@@ -4,4 +4,5 @@ pkg/*
.idea
.rspec
.rvmrc
+coverage
Gemfile.lock
View
@@ -2,4 +2,4 @@ Dir[File.expand_path("tasks/**/*.rb")].each do |task_file|
require task_file
end
-task :default => [ :rspec ]
+task :default => [ :spec ]
View
@@ -15,4 +15,5 @@ Gem::Specification.new do |s|
s.require_path = "lib"
s.files = Dir["lib/**/*", "spec/**/*", "tasks/**/*", "Rakefile"] + s.extra_rdoc_files
s.add_development_dependency("rspec", "~> 2")
+ s.add_development_dependency("simplecov", "~> 0.2")
end
View
@@ -1,5 +1,14 @@
# Common spec-related code goes here
+require 'simplecov'
+SimpleCov.start 'rails'
+SimpleCov.at_exit do
+ SimpleCov.result.format!
+ open("#{SimpleCov.coverage_dir}/covered_percent", "w") do |f|
+ f.puts SimpleCov.result.covered_percent.to_s
+ end
+end
+
STACK_OVERFLOW_DEPTH = if RUBY_ENGINE == "ruby"
def calculate_stack_overflow_depth(n)
calculate_stack_overflow_depth(n + 1)
View
@@ -1,4 +0,0 @@
-require 'rspec/core/rake_task'
-
-desc "Run specifications"
-RSpec::Core::RakeTask.new(:rspec)
View
@@ -0,0 +1,13 @@
+require 'rspec/core/rake_task'
+
+desc "Run specifications"
+RSpec::Core::RakeTask.new(:spec)
+
+# task :spec do
+# covered_threshold = 100
+# covered_percent = Float(File.read("coverage/covered_percent"))
+# if covered_percent < covered_threshold
+# $stderr.puts ""
+# raise "Insufficient unit-test coverage (#{covered_percent} < #{covered_threshold})"
+# end
+# end

0 comments on commit 7c6317e

Please sign in to comment.