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.
6 7 8 9 10 11 12 13 14 |
# File 'lib/oncall/core/reporter.rb', line 6 def initialize @results = { failure: 0, success: 0, empty: 0 } = [] end |
Instance Method Details
#finish ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/oncall/core/reporter.rb', line 27 def finish puts "\n\n" puts result = "\n#{@results[:success]} passed, #{@results[:failure]} failed.\n" if success? puts result.green else puts result.red end end |
#report(tests) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/oncall/core/reporter.rb', line 16 def report(tests) start begin yield self ensure finish end end |
#report_empty_group ⇒ Object
44 45 46 47 |
# File 'lib/oncall/core/reporter.rb', line 44 def report_empty_group print '*' @results[:empty] = @results[:empty] + 1 end |
#report_status(result, message) ⇒ Object
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/oncall/core/reporter.rb', line 49 def report_status(result, ) if result print '.' @results[:success] = @results[:success] + 1 else print 'F' @results[:failure] = @results[:failure] + 1 << end end |
#start ⇒ Object
25 |
# File 'lib/oncall/core/reporter.rb', line 25 def start; end |
#success? ⇒ Boolean
40 41 42 |
# File 'lib/oncall/core/reporter.rb', line 40 def success? @results[:failure].zero? && @results[:empty].zero? end |