Class: RailsDoctor::Adapters::TestCoverage

Inherits:
Base
  • Object
show all
Defined in:
lib/rails_doctor/adapters/test_coverage.rb

Constant Summary collapse

NAME =
"test_coverage"
DEFAULT_LINE_THRESHOLD =
90.0
DEFAULT_FILE_LINE_THRESHOLD =
80.0
InvalidCoverageReport =
Class.new(StandardError)

Instance Attribute Summary

Attributes inherited from Base

#changed_files, #config, #profile, #project, #runner

Instance Method Summary collapse

Methods inherited from Base

#command, #initialize, #name, #unavailable_reason

Constructor Details

This class inherits a constructor from RailsDoctor::Adapters::Base

Instance Method Details

#available?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/rails_doctor/adapters/test_coverage.rb', line 11

def available?
  true
end

#install_guidanceObject



15
16
17
# File 'lib/rails_doctor/adapters/test_coverage.rb', line 15

def install_guidance
  "Add gem \"simplecov\" to development/test and require it before the test framework boots."
end

#runObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/rails_doctor/adapters/test_coverage.rb', line 19

def run
  started = Process.clock_gettime(Process::CLOCK_MONOTONIC)
  coverage, findings, stderr, exit_status = coverage_result
  duration_ms = ((Process.clock_gettime(Process::CLOCK_MONOTONIC) - started) * 1000).round

  {
    tool_run: ToolRun.new(
      name: name,
      available: true,
      skipped: false,
      exit_status: exit_status,
      duration_ms: duration_ms,
      stderr: stderr,
      metadata: { coverage: coverage.to_h }
    ),
    findings: findings,
    coverage: coverage
  }
end