Parent

Class Index [+]

Quicksearch

Merb::Counter

Attributes

time[RW]

Public Class Methods

new() click to toggle source
    # File lib/merb-core/test/run_specs.rb, line 22
22:     def initialize
23:       @examples, @failures, @errors, @pending, @total_time = 0, 0, 0, 0, 0
24:       @err = ""
25:       @mutex = Mutex.new
26:     end

Public Instance Methods

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

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.