Class | Merb::Counter |
In: |
merb-core/lib/merb-core/test/run_specs.rb
|
Parent: | Object |
time | [RW] |
# File merb-core/lib/merb-core/test/run_specs.rb, line 29 29: def initialize 30: @examples, @failures, @errors, @pending, @total_time = 0, 0, 0, 0, 0 31: @err = "" 32: @mutex = Mutex.new 33: end
# File merb-core/lib/merb-core/test/run_specs.rb, line 39 39: def add(spec, out, err) 40: @mutex.synchronize do 41: puts 42: puts "Running #{spec}." 43: STDOUT.puts out 44: STDOUT.flush 45: match = out.match(/(\d+) examples?, (\d+) failures?(?:, (\d+) errors?)?(?:, (\d+) pending?)?/m) 46: time = out.match(/Finished in (\d+\.\d+) seconds/) 47: @total_time += time[1].to_f if time 48: if match 49: e, f, errors, pending = match[1..-1] 50: @examples += e.to_i 51: @failures += f.to_i 52: @errors += errors.to_i 53: @pending += pending.to_i 54: end 55: unless err.chomp.empty? 56: @err << err.chomp << "\n" 57: end 58: end 59: end
# File merb-core/lib/merb-core/test/run_specs.rb, line 61 61: def report 62: i = 0 63: @err.gsub!(/^\d*\)\s*/) do 64: "#{i += 1})\n" 65: end 66: 67: puts @err 68: puts 69: if @failures != 0 || @errors != 0 70: print "\e[31m" # Red 71: elsif @pending != 0 72: print "\e[33m" # Yellow 73: else 74: print "\e[32m" # Green 75: end 76: puts "#{@examples} examples, #{@failures} failures, #{@errors} errors, #{@pending} pending, #{sprintf("suite run in %3.3f seconds", @time.real)}" 77: # TODO: we need to report pending examples all together 78: puts "\e[0m" 79: end