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
11
12
# File 'lib/oncall/core/reporter.rb', line 4

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

  @messages = []
end

Instance Method Details

#finishObject



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

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

#report(tests) ⇒ Object



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

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

#report_empty_groupObject



35
36
37
38
# File 'lib/oncall/core/reporter.rb', line 35

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

#report_status(result, message) ⇒ Object



40
41
42
43
44
45
46
47
48
49
# File 'lib/oncall/core/reporter.rb', line 40

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

#startObject



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

def start; end

#success?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/oncall/core/reporter.rb', line 31

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