Sha256: 69c7990ca37de5e07dc45a380280fe264f8081ae7f1eb8e5770019571cdc700a

Contents?: true

Size: 1.49 KB

Versions: 1

Compression:

Stored size: 1.49 KB

Contents

module Turn
  require 'turn/colorize'
  require 'turn/core_ext'

  # = Reporter
  #
  # There are two distinct way in which a report may be utilized
  # by a Runner: per-call or per-file. The method #pass, #fail
  # and #error are generic, and will be used in either case.
  # A per-call runner will use all the methods of a Reporter,
  # while a per-file runner will use start_case per file,
  # and will not use the start_test and finish_test methods,
  # since those are beyond it's grainularity.
  #
  class Reporter

    include Colorize

    attr :io

    def initialize(io, opts={})
      @io      = io || $stdout
      @trace   = opts[:trace]
      @natural = opts[:natural]
    end

    # These methods are called in the process of running the tests.

    def start_suite(test_suite)
    end

    def start_case(test_case)
    end

    def start_test(test)
    end

    def pass(message=nil)
    end

    def fail(assertion, message=nil)
    end

    def error(exception, message=nil)
    end

    def finish_test(test)
    end

    def finish_case(test_case)
    end

    def finish_suite(test_suite)
    end

  private

    # TODO: backtrace filter probably could use some refinement.
    def filter_backtrace(bt)
      return [] unless bt
      bt.reject!{ |line| line.rindex('minitest') }
      bt.reject!{ |line| line.rindex('test/unit') }
      bt.reject!{ |line| line.rindex('lib/turn') }
      bt.reject!{ |line| line.rindex('bin/turn') }
      bt.map{ |line| line.sub(Dir.pwd+'/', '') }
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
turn-0.8.3 lib/turn/reporter.rb