Module: RubyLsp::PreventReporterOverridePatch

Defined in:
lib/ruby_lsp/test_reporters/minitest_reporter.rb

Overview

This patch is here to prevent other gems from overriding or adding more Minitest reporters. Otherwise, they may break the integration between the server and extension

Class Attribute Summary collapse

Instance Method Summary collapse

Class Attribute Details

.lsp_reportersObject

: Array



40
41
42
# File 'lib/ruby_lsp/test_reporters/minitest_reporter.rb', line 40

def lsp_reporters
  @lsp_reporters
end

Instance Method Details

#reportersObject

Patch the reader to prevent appending more reporters. This method always returns a temporary copy of the real reporters so that if any gem mutates it, it continues to return the original reporters : -> Array



52
53
54
# File 'lib/ruby_lsp/test_reporters/minitest_reporter.rb', line 52

def reporters
  PreventReporterOverridePatch.lsp_reporters.dup
end

#reporters=(reporters) ⇒ Object

Patch the writer to prevent replacing the entire array : (untyped) -> void



45
46
47
# File 'lib/ruby_lsp/test_reporters/minitest_reporter.rb', line 45

def reporters=(reporters)
  # Do nothing. We don't want other gems to override our reporter
end