Module: Test::Unit::Coverage

Defined in:
lib/test/unit/coverage.rb

Defined Under Namespace

Classes: Collector, DefaultPrinter

Constant Summary collapse

@@enable =
nil
@@printer =
nil

Class Method Summary collapse

Class Method Details

.disable(auto_runner) ⇒ Object



19
20
21
22
23
# File 'lib/test/unit/coverage.rb', line 19

def disable(auto_runner)
  auto_runner.listeners.reject! do |listener|
    listener.is_a?(Coverage::Collector)
  end
end

.enable(auto_runner) ⇒ Object



15
16
17
# File 'lib/test/unit/coverage.rb', line 15

def enable(auto_runner)
  auto_runner.listeners << Collector.new
end

.enable=(enable) ⇒ Object



26
27
28
# File 'lib/test/unit/coverage.rb', line 26

def enable=(enable)
  @@enable = enable
end

.enable?Boolean

Returns:

  • (Boolean)


30
31
32
33
34
35
# File 'lib/test/unit/coverage.rb', line 30

def enable?
  if @@enable.nil?
    @@enable = Collector.available?
  end
  @@enable
end

.printerObject



46
47
48
# File 'lib/test/unit/coverage.rb', line 46

def printer
  @@printer
end

.printer=(printer) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/test/unit/coverage.rb', line 38

def printer=(printer)
  if enable?
    @@printer = printer
  else
    warn "coverage is disabled."
  end
end