.simplecov in active_model_serializers-0.10.0.rc3 vs .simplecov in active_model_serializers-0.10.0.rc4

- old
+ new

@@ -39,32 +39,44 @@ # Exclude these paths from analysis add_filter '/config/' add_filter '/db/' add_filter 'tasks' + add_filter '/.bundle/' end ## START TRACKING COVERAGE (before activating SimpleCov) require 'coverage' Coverage.start ## ADD SOME CUSTOM REPORTING AT EXIT SimpleCov.at_exit do + next if $! and not ($!.kind_of? SystemExit and $!.success?) + header = "#{'*' * 20} SimpleCov Results #{'*' * 20}" - @output.puts - @output.puts header - @output.puts SimpleCov.result.format! + results = SimpleCov.result.format!.join("\n") + exit_message = <<-EOF + +#{header} +{{RESULTS}} +{{FAILURE_MESSAGE}} + +#{'*' * header.size} + EOF percent = Float(SimpleCov.result.covered_percent) if percent < @minimum_coverage - @output.puts "Spec coverage was not high enough: "\ - "#{percent.round(2)} is < #{@minimum_coverage}%\n" - exit 1 if @generate_report - else - @output.puts "Nice job! Spec coverage (#{percent.round(2)}) "\ - "is still at or above #{@minimum_coverage}%\n" + failure_message = <<-EOF +Spec coverage was not high enough: #{percent.round(2)}% is < #{@minimum_coverage}% + EOF + exit_message.sub!('{{RESULTS}}', results).sub!('{{FAILURE_MESSAGE}}', failure_message) + @output.puts exit_message + abort(failure_message) if @generate_report + elsif @running_ci + exit_message.sub!('{{RESULTS}}', results).sub!('{{FAILURE_MESSAGE}}', <<-EOF) +Nice job! Spec coverage (#{percent.round(2)}%) is still at or above #{@minimum_coverage}% + EOF + @output.puts exit_message end - @output.puts - @output.puts '*' * header.size end ## CAPTURE CONFIG IN CLOSURE 'AppCoverage.start' ## to defer running until test/test_helper.rb is loaded. # rubocop:disable Style/MultilineBlockChain