Sha256: d94d7610e067971a88adb743f33f338f5a17358998862ffcabd0561bc7c341cd

Contents?: true

Size: 1.8 KB

Versions: 5

Compression:

Stored size: 1.8 KB

Contents

require 'turn/reporter'

module Turn

  # = Outline Reporter (Turn's Original)
  #
  #--
  # TODO: Should we fit reporter output to width of console?
  # TODO: Running percentages?
  #++
  class OutlineReporter < Reporter

    def start_suite(suite)
      @suite = suite
      @time  = Time.now
      #files = suite.collect{ |s| s.file }.join(' ')
      io.puts "Loaded suite #{suite.name}"
      #io.puts "Started"
    end

    def start_case(kase)
      io.puts(kase.name)
    end

    def start_test(test)
      #if @file != test.file
      #  @file = test.file
      #  io.puts(test.file)
      #end
      io.print "    %-69s" % test.name
    end

    def pass(message=nil)
      io.puts " #{PASS}"
      if message
        message = ::ANSICode.magenta(message) if COLORIZE
        message = message.to_s.tabto(8)
        io.puts(message)
      end
    end

    def fail(message=nil)
      io.puts(" #{FAIL}")
      if message
        message = ::ANSICode.magenta(message) if COLORIZE
        message = message.to_s.tabto(8)
        io.puts(message)
      end
    end

    def error(message=nil)
      io.puts("#{ERROR}")
      io.puts(message.to_s) if message
    end

    def finish_test(test)
    end

    #def finish_case(kase)
    #end

    def finish_suite(suite)
      total   = suite.count_tests
      failure = suite.count_failures
      error   = suite.count_errors
      pass    = total - failure - error

      bar = '=' * 78
      if COLORIZE
        bar = if pass == total then ::ANSICode.green bar
              else ::ANSICode.red bar end
      end

      tally = [total, suite.count_assertions]

      io.puts bar
      io.puts "  pass: %d,  fail: %d,  error: %d" % [pass, failure, error]
      io.puts "  total: %d tests with %d assertions in #{Time.new - @time} seconds" % tally
      io.puts bar
    end

  end

end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
TwP-turn-0.5.1 lib/turn/reporters/outline_reporter.rb
TwP-turn-0.6.0 lib/turn/reporters/outline_reporter.rb
turn-0.4.0 lib/turn/reporters/outline_reporter.rb
turn-0.6.0 lib/turn/reporters/outline_reporter.rb
turn-0.5.1 lib/turn/reporters/outline_reporter.rb