Sha256: 6da95b12dd2a44dd33a36ad712bdae7bd5ab7f63884b0efb396b876cb986844b

Contents?: true

Size: 997 Bytes

Versions: 5

Compression:

Stored size: 997 Bytes

Contents

require "simplecov-console"

running_full_suite = RSpec.configuration.files_to_run.size > 1 && !RSpec.configuration.only_failures
use_console_formatter = running_full_suite

coverage_for = ENV['COVERAGE_FOR']

formatters = [SimpleCov::Formatter::HTMLFormatter]
if use_console_formatter
  formatters << SimpleCov::Formatter::Console
end

SimpleCov.start 'rails' do
  coverage_dir 'tmp/coverage'

  formatter SimpleCov::Formatter::MultiFormatter.new(formatters)

  # refuse_coverage_drop if ENV['CI'].present?

  add_filter do |source_file|
    # TODO: Should the next line technically have a 'if coverage_for.present?' at the end?
    (source_file.filename =~ /#{coverage_for}/i).nil?
  end
end

SimpleCov.at_exit do
  SimpleCov.result.format!

  puts "To view detailed code coverage, run this: open tmp/coverage/index.html"
  if use_console_formatter
    if coverage_for != nil && coverage_for != ""
      puts "Reporting test coverage ONLY for files matching /#{coverage_for}/"
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
hub_spot-0.3.1 .simplecov
hub_spot-0.3.0 .simplecov
hub_spot-0.2.1 .simplecov
hub_spot-0.2.0 .simplecov
hub_spot-0.1.0 .simplecov