Class: Merb::Counter
- Includes:
- DRb::DRbUndumped
- Defined in:
- lib/merb-core/test/run_specs.rb
Instance Attribute Summary collapse
-
#time ⇒ Object
Returns the value of attribute time.
Instance Method Summary collapse
- #add(spec, out, err) ⇒ Object
-
#initialize ⇒ Counter
constructor
A new instance of Counter.
- #report ⇒ Object
Constructor Details
#initialize ⇒ Counter
Returns a new instance of Counter.
47 48 49 50 51 |
# File 'lib/merb-core/test/run_specs.rb', line 47 def initialize @examples, @failures, @errors, @pending, @total_time = 0, 0, 0, 0, 0 @err = "" @mutex = Mutex.new end |
Instance Attribute Details
#time ⇒ Object
Returns the value of attribute time.
46 47 48 |
# File 'lib/merb-core/test/run_specs.rb', line 46 def time @time end |
Instance Method Details
#add(spec, out, err) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/merb-core/test/run_specs.rb', line 53 def add(spec, out, err) @mutex.synchronize do puts puts "Running #{spec}." STDOUT.puts out STDOUT.flush match = out.match(/(\d+) examples?, (\d+) failures?(?:, (\d+) errors?)?(?:, (\d+) pending?)?/m) time = out.match(/Finished in (\d+\.\d+) seconds/) @total_time += time[1].to_f if time if match e, f, errors, pending = match[1..-1] @examples += e.to_i @failures += f.to_i @errors += errors.to_i @pending += pending.to_i end unless err.chomp.empty? @err << err.chomp << "\n" end end end |
#report ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/merb-core/test/run_specs.rb', line 75 def report puts @err puts if @failures != 0 || @errors != 0 print "\e[31m" # Red elsif @pending != 0 print "\e[33m" # Yellow else print "\e[32m" # Green end puts "Total actual time: #{@total_time}" puts "#{@examples} examples, #{@failures} failures, #{@errors} errors, #{@pending} pending, #{sprintf("suite run in %3.3f seconds", @time.real)}" # TODO: we need to report pending examples all together puts "\e[0m" end |