Class: Minitest::ViewsCoverage

Inherits:
AbstractReporter
  • Object
show all
Defined in:
lib/minitest/views_coverage_plugin.rb

Constant Summary collapse

NO_TEMPLATE_IDENTIFIERS =
['html template', 'text template'].freeze
RESULT_FILENAME_PREFIX =
'views_coverage_result_'.freeze
MERGE_MODE_FLAG =
'merge'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ ViewsCoverage

Returns a new instance of ViewsCoverage.



7
8
9
10
11
12
# File 'lib/minitest/views_coverage_plugin.rb', line 7

def initialize(options)
  super()
  @mode = options.delete(:mode) || 'clean'
  @coverage_result = {}
  subscribe_to_notifications
end

Instance Method Details

#prerecord(klass, _name) ⇒ Object



14
15
16
# File 'lib/minitest/views_coverage_plugin.rb', line 14

def prerecord(klass, _name)
  @test_type = klass < ActionDispatch::SystemTestCase ? :system : :unit
end

#reportObject



18
19
20
21
22
# File 'lib/minitest/views_coverage_plugin.rb', line 18

def report
  write_result(@coverage_result[:unit], :unit) if @coverage_result[:unit].present?
  write_result(@coverage_result[:system], :system) if @coverage_result[:system].present?
  write_merged_result if @mode == MERGE_MODE_FLAG
end