Class: Oncall::Core::Reporter
- Inherits:
-
Object
- Object
- Oncall::Core::Reporter
- Defined in:
- lib/oncall/core/reporter.rb
Instance Method Summary collapse
- #finish ⇒ Object
-
#initialize ⇒ Reporter
constructor
A new instance of Reporter.
- #report(tests) ⇒ Object
- #report_empty_group ⇒ Object
- #report_status(result, message) ⇒ Object
- #start ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize ⇒ Reporter
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
#finish ⇒ Object
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_group ⇒ Object
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, ) if result print '.' @results[:success] = @results[:success] + 1 else print 'F' @results[:failure] = @results[:failure] + 1 @messages << end end |
#start ⇒ Object
23 |
# File 'lib/oncall/core/reporter.rb', line 23 def start; end |
#success? ⇒ Boolean
31 32 33 |
# File 'lib/oncall/core/reporter.rb', line 31 def success? @results[:failure].zero? && @results[:empty].zero? end |