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 15 16 |
# File 'lib/oncall/core/reporter.rb', line 6 def initialize @results = { failure: 0, success: 0, empty: 0 } @start_time = nil @end_time = nil @messages = [] end |
Instance Method Details
#finish ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/oncall/core/reporter.rb', line 31 def finish @end_time = Time.now puts "\n\n" puts @messages elapsed_seconds = (@end_time.to_f - @start_time.to_f).to_f puts "Finished in #{elapsed_seconds.round(4)} seconds" result = "#{@results[:success]} passed, #{@results[:failure]} failed.\n" if success? puts result.green else puts result.red end end |
#report(tests) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/oncall/core/reporter.rb', line 18 def report(tests) start begin yield self ensure finish end end |
#report_empty_group ⇒ Object
53 54 55 56 |
# File 'lib/oncall/core/reporter.rb', line 53 def report_empty_group print '*' @results[:empty] = @results[:empty] + 1 end |
#report_status(result, message) ⇒ Object
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/oncall/core/reporter.rb', line 58 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
27 28 29 |
# File 'lib/oncall/core/reporter.rb', line 27 def start @start_time = Time.now end |
#success? ⇒ Boolean
49 50 51 |
# File 'lib/oncall/core/reporter.rb', line 49 def success? @results[:failure].zero? && @results[:empty].zero? end |