Class: Oncall::Core::Reporter

Inherits:
Object
  • Object
show all
Defined in:
lib/oncall/core/reporter.rb

Instance Method Summary collapse

Constructor Details

#initializeReporter

Returns a new instance of Reporter.



4
5
6
7
8
9
10
# File 'lib/oncall/core/reporter.rb', line 4

def initialize
  @results  = {
    failure: 0,
    success: 0,
    empty: 0
  }
end

Instance Method Details

#finishObject



24
25
26
27
# File 'lib/oncall/core/reporter.rb', line 24

def finish
  puts "\n"
  puts "#{@results[:success]} passed, #{@results[:failure]} failed."
end

#report(tests) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/oncall/core/reporter.rb', line 12

def report(tests)
  start
  begin
    yield self
  ensure
    finish
  end
end

#report_empty_groupObject



33
34
35
36
# File 'lib/oncall/core/reporter.rb', line 33

def report_empty_group
  print 'E'
  @results[:empty] = @results[:empty] + 1
end

#report_status(result) ⇒ Object



38
39
40
41
42
43
44
45
46
# File 'lib/oncall/core/reporter.rb', line 38

def report_status(result)
  if result
    print '.'
    @results[:success] = @results[:success] + 1
  else
    print 'F'
    @results[:failure] = @results[:failure] + 1
  end
end

#startObject



21
22
# File 'lib/oncall/core/reporter.rb', line 21

def start
end

#success?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/oncall/core/reporter.rb', line 29

def success?
  @results[:failure].zero? && @results[:empty].zero?
end