Class: QED::Reporter::Verbatim

Inherits:
Abstract
  • Object
show all
Defined in:
lib/qed/reporter/verbatim.rb

Overview

Verbose ANSI Console Reporter

Instance Attribute Summary

Attributes inherited from Abstract

#io, #omit, #steps

Instance Method Summary collapse

Methods inherited from Abstract

After, Before, When, #after_code, #after_document, #after_session, #before_code, #before_document, #before_session, #code, #errors, #failures, #import, #initialize, #load, #passes, #trace?, #unload, #update, #when

Constructor Details

This class inherits a constructor from QED::Reporter::Abstract

Instance Method Details

#error(step, error) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/qed/reporter/verbatim.rb', line 49

def error(step, error)
  raise error if $DEBUG
  txt = step.text.rstrip.sub("\n",'')
  tab = step.text.index(/\S/) - 1
  io.print "#{txt}\n\n".ansi(:red)
  msg = []
  msg << "ERROR: #{error.class} ".ansi(:bold,:red) + error.to_str #.sub(/for QED::Context.*?$/,'')
  msg << clean_backtrace(error.backtrace[0]).ansi(:bold)
  #msg = msg.ansi(:red)
  io.puts msg.join("\n").tabto(tab||2)
  io.puts
end

#fail(step, error) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/qed/reporter/verbatim.rb', line 35

def fail(step, error)
  txt = step.text.rstrip.sub("\n",'')
  tab = step.text.index(/\S/) - 1
  io.print "#{txt}\n\n".ansi(:red)
  msg = []
  #msg << ANSI::Code.bold(ANSI::Code.red("FAIL: ")) + error.to_str
  #msg << ANSI::Code.bold(clean_backtrace(error.backtrace[0]))
  msg << "FAIL: ".ansi(:bold, :red) + error.to_str
  msg << clean_backtrace(error.backtrace[0]).ansi(:bold)
  io.puts msg.join("\n").tabto(tab||2)
  io.puts
end

#pass(step) ⇒ Object



29
30
31
32
# File 'lib/qed/reporter/verbatim.rb', line 29

def pass(step)
  txt = step.text.rstrip.sub("\n",'')
  io.print "#{txt}\n\n".ansi(:green)
end

#text(section) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/qed/reporter/verbatim.rb', line 11

def text(section)
  case section.text
  when /^\=/
    io.puts "#{section.text}".ansi(:bold)
  else
    io.puts(section.text + "\n")
  end
  if !section.cont.empty?
    section.cont.each do |c|
      io.puts(c.ansi(:blue))
      io.puts
    end
  end
end