Sha256: 81db8a711f093f53935b8b82f681320d116f2285e825efdbd4198ac8bf602fc2

Contents?: true

Size: 1.92 KB

Versions: 1

Compression:

Stored size: 1.92 KB

Contents

require 'quarry/reporter'

module Quarry

  class Reporter #:nodoc:

    # = Verbatim Reporter
    #
    class Verbatim < Reporter

      #def report_step(step)
      #  super
      #  if step.code
      #    #str = "(%s) %s" % [count.join('.'), str.tab(6).strip]
      #    #puts "* #{step.to_s.tab(2).strip}"
      #    #puts
      #    #puts step.to_s
      #    #puts
      #  else
      #    #puts "#{step}\n"  # TODO: This never happens.
      #  end
      #end

      def report_header(step)
        puts ANSICode.bold("#{step}")
        #puts
      end

      def report_comment(step)
        puts step
        #puts
      end

      #
      def report_macro(step)
        #puts
        #puts step.text
        puts ANSICode.magenta("#{step}")
        #puts
      end

      #
      def report_pass(step)
        puts ANSICode.green("#{step}")
        #puts
      end

      def report_fail(step, error)
        tab = step.tab #step.to_s.index(/\S/)
        puts ANSICode.red("#{step}")
        puts
        msg = []
        msg << ANSICode.bold(ANSICode.red("FAIL: ")) + error.to_str
        msg << ANSICode.bold(error.backtrace[0].chomp(":in \`run'"))          
        puts msg.join("\n").tabto(tab||2)
        #puts
      end

      def report_error(step, error)
        raise error if $DEBUG
        tab = step.tab #step.to_s.index(/\S/)
        puts ANSICode.red("#{step}")
        puts
        msg = []
        msg << ANSICode.bold(ANSICode.red("ERROR: ")) + error.to_str.sub(/for Quarry::Context.*?$/,'')
        msg << ANSICode.bold(error.backtrace[0].chomp(":in \`run'"))
        #msg = ANSICode.red(msg)
        puts msg.join("\n").tabto(tab||2)
        #puts
      end

      def report_step_end(step)
        puts
      end

      #def report(str)
      #  count[-1] += 1 unless count.empty?
      #  str = str.chomp('.') + '.'
      #  str = count.join('.') + ' ' + str
      #  puts str.strip
      #end

    end

  end

end #module Quarry

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
quarry-0.5.2 lib/quarry/reporter/verbatim.rb