Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Several extract-method refactors in code-coverage test helper

  • Loading branch information...
commit 6f712bf825ab2e6cb6a756dbf2456ef61261acb3 1 parent 2cc899b
@chrisk authored
Showing with 23 additions and 13 deletions.
  1. +23 −13 test/helpers/start_simplecov.rb
View
36 test/helpers/start_simplecov.rb
@@ -1,7 +1,7 @@
module FakeWebTestHelper
module CodeCoverage
def start_simplecov
- return unless RUBY_VERSION >= "1.9.0"
+ return unless coverage_supported_by_this_ruby?
return if !ENV['AUTOTEST'].nil?
require 'simplecov'
@@ -11,19 +11,17 @@ def start_simplecov
add_filter "/test/"
minimum_coverage 100 if running_all_tests?
+ command_name SIMPLECOV_COMMAND_NAME if child_test_process?
+ formatter simplecov_formatter_class
+ end
+ end
- if defined?(SIMPLECOV_COMMAND_NAME)
- command_name SIMPLECOV_COMMAND_NAME
- end
-
- if !ENV["COVERAGE_REPORT"].nil?
- formatter SimpleCov::Formatter::MultiFormatter[
- SimpleCov::Formatter::HTMLFormatter,
- SimpleCov::Formatter::Console
- ]
- else
- formatter SimpleCov::Formatter::Console
- end
+ def simplecov_formatter_class
+ include SimpleCov::Formatter
+ if html_report_requested?
+ MultiFormatter[HTMLFormatter, Console]
+ else
+ Console
end
end
@@ -31,6 +29,18 @@ def running_all_tests?
ENV['TEST'].nil?
end
+ def child_test_process?
+ defined?(SIMPLECOV_COMMAND_NAME)
+ end
+
+ def html_report_requested?
+ !ENV["COVERAGE_REPORT"].nil?
+ end
+
+ def coverage_supported_by_this_ruby?
+ RUBY_VERSION >= "1.9.0"
+ end
+
extend self
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.