Parent

Class/Module 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
def initialize
  @examples, @failures, @errors, @pending, @total_time = 0, 0, 0, 0, 0
  @err = ""
  @mutex = Mutex.new
end

Public Instance Methods

add(spec, out, err) click to toggle source
# File lib/merb-core/test/run_specs.rb, line 32
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?)?/)
    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
failed?() click to toggle source
# File lib/merb-core/test/run_specs.rb, line 28
def failed?
  @failures > 0
end
report() click to toggle source
# File lib/merb-core/test/run_specs.rb, line 54
def report
  i = 0
  @err.gsub!(/^\d*\)\s*/) do
    "#{i += 1})\n"
  end
  
  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 "#{@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

[Validate]

Generated with the Darkfish Rdoc Generator 2.