Skip to content

Commit

Permalink
Add simplecov for coverage reports
Browse files Browse the repository at this point in the history
  • Loading branch information
harukizaemon committed Mar 7, 2011
1 parent 2985a65 commit 7c6317e
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -4,4 +4,5 @@ pkg/*
.idea
.rspec
.rvmrc
coverage
Gemfile.lock
2 changes: 1 addition & 1 deletion Rakefile
Expand Up @@ -2,4 +2,4 @@ Dir[File.expand_path("tasks/**/*.rb")].each do |task_file|
require task_file
end

task :default => [ :rspec ]
task :default => [ :spec ]
1 change: 1 addition & 0 deletions hamster.gemspec
Expand Up @@ -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
9 changes: 9 additions & 0 deletions spec/spec_helper.rb
@@ -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)
Expand Down
4 changes: 0 additions & 4 deletions tasks/rspec.rb

This file was deleted.

13 changes: 13 additions & 0 deletions tasks/spec.rb
@@ -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.