Sha256: 9c6403a83dbf1826c26c5d06427e4167f78bc789d4964e5351315cff403dc153

Contents?: true

Size: 1.41 KB

Versions: 9

Compression:

Stored size: 1.41 KB

Contents

require 'turn/reporter'

module Turn

  # = Traditional Dot Reporter
  #
  class DotReporter < Reporter

    def start_suite(suite)
      @time = Time.now
      io.puts "Loaded suite #{suite.name}"
      io.puts "Started"
    end

    def start_case(kase)
    end

    def start_test(test)
    end

    def pass(message=nil)
      io.print '.'; io.flush
    end

    def fail(message=nil)
      io.print 'F'; io.flush
    end

    def error(message=nil)
      io.print 'E'; io.flush
    end

    def finish_test(test)
    end

    def finish_case(kase)
    end

    def finish_suite(suite)
      io.puts("\nFinished in %.5f seconds." % [Time.now - @time])
      io.puts

      report = ''

      fails = suite.select do |testrun|
        testrun.fail? || testrun.error?
      end

      unless fails.empty? # or verbose?
        #report << "\n\n-- Failures and Errors --\n\n"
        fails.uniq.each do |testrun|
          message = testrun.message.tabto(0)
          message = ::ANSICode.magenta(message) if COLORIZE
          report << message << "\n"
        end
        report << "\n"
      end

      io.puts report

      io.puts "%s tests, %s assetions, %s failures, %s errors" % test_tally(suite)
    end

  private

    def test_tally(suite)
      counts = suite.collect{ |tr| tr.counts }
      tally  = [0,0,0,0]
      counts.each do |count|
        4.times{ |i| tally[i] += count[i] }
      end
      return tally
    end

  end

end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
TwP-turn-0.5.1 lib/turn/reporters/dot_reporter.rb
TwP-turn-0.6.0 lib/turn/reporters/dot_reporter.rb
turn-0.7.0 lib/turn/reporters/dot_reporter.rb
turn-0.6.3 lib/turn/reporters/dot_reporter.rb
turn-0.6.2 lib/turn/reporters/dot_reporter.rb
turn-0.6.1 lib/turn/reporters/dot_reporter.rb
turn-0.4.0 lib/turn/reporters/dot_reporter.rb
turn-0.5.1 lib/turn/reporters/dot_reporter.rb
turn-0.6.0 lib/turn/reporters/dot_reporter.rb