diff --git a/spec/coverage_helper.rb b/spec/coverage_helper.rb index 8004b30..2e2b2d9 100644 --- a/spec/coverage_helper.rb +++ b/spec/coverage_helper.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: true # Simultaneous code coverage reporting to Coveralls and Code Climate. # Latest version can be found at https://gist.github.com/lowjoel/6c2f2d3a08bb3786994f require 'simplecov' @@ -8,19 +9,16 @@ class << self # gem. # # @param [String] name The name of the module to require. - # @param [Proc] initializer The block to execute when the module is required successfully. - def load(name, &initializer) + # @yield The block to execute when the module is required successfully. + def load(name) old_formatter = SimpleCov.formatter require name - initializer.call + yield merge_formatters(old_formatter, SimpleCov.formatter) rescue LoadError => e - if e.path == name - puts format('Cannot find \'%s\', ignoring', name) if ENV['CI'] - else - raise e - end + raise e unless e.path == name + puts format('Cannot find \'%s\', ignoring', name) if ENV['CI'] end private