Sha256: 945a821e9c5954944fac5afb0f0971bb38c829f9accf463ca4667d5e67b3d03e

Contents?: true

Size: 1.94 KB

Versions: 2

Compression:

Stored size: 1.94 KB

Contents

module QED
module Reporter #:nodoc:

  require 'qed/reporter/base'

  # = Verbatim Reporter
  #
  class Verbatim < BaseClass

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

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

    def report_comment(step)
      io.puts step
      #io.puts
    end

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

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

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

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

    def report_step_end(step)
      io.puts
    end

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

    #def report_table(set)
    #  puts ANSICode.magenta(set.to_yaml.tabto(2))
    #end

  end

end #module
end #module QED

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
qed-1.1.0 lib/qed/reporter/verbatim.rb
qed-1.0.0 lib/qed/reporter/verbatim.rb