Permalink
Browse files

Several extract-method refactors in code-coverage test helper

  • Loading branch information...
1 parent 2cc899b commit 6f712bf825ab2e6cb6a756dbf2456ef61261acb3 @chrisk committed Nov 24, 2013
Showing with 23 additions and 13 deletions.
  1. +23 −13 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,26 +11,36 @@ 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
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

0 comments on commit 6f712bf

Please sign in to comment.