class QED::Reporter::Linear

Linear reporter limits each step to a single line.

Public Instance Methods

after_session(session) click to toggle source
# File lib/qed/reporter/linear.rb, line 88
def after_session(session)
  puts "[INFO] %s demos, %s steps: %s failures, %s errors (%s/%s assertions)" % get_tally
  puts "[INFO] Finished in %.5f seconds." % [Time.now - @start_time]
  puts "[INFO] End Session @ #{Time.now}".ansi(:bold)
end
before_applique(step) click to toggle source
Calls superclass method
# File lib/qed/reporter/linear.rb, line 25
def before_applique(step)
  super(step)
  #post
  str = "[NOTE] #{step.explain.gsub(/\s+/,' ')} "[0,@width]
  pad = @width - str.size + 1
  print str + (' ' * pad)
  puts "[#{timestamp}]"
end
before_demo(demo) click to toggle source
# File lib/qed/reporter/linear.rb, line 19
def before_demo(demo)
  file = localize_file(demo.file)
  puts "[DEMO] #{file}".ansi(:bold)
end
before_session(session) click to toggle source
# File lib/qed/reporter/linear.rb, line 12
def before_session(session)
  @width = ANSI::Terminal.terminal_width - 12
  @start_time = Time.now
  puts "[INFO] Session @ #{Time.now}".ansi(:bold)
end
error(step, exception) click to toggle source
Calls superclass method QED::Reporter::Abstract#error
# File lib/qed/reporter/linear.rb, line 67
def error(step, exception)
  super(step, exception)

  print_step(step, 'ERRO', :red)

  #puts "ERROR".ansi(:red)

  s = []
  s << assertion.class.name
  s << assertion.message

  backtrace = sane_backtrace(assertion)
  backtrace.each do |bt|
    s << bt
    s << code_snippet(bt)
  end

  puts s.join("\n").tabto(8)
end
fail(step, assertion) click to toggle source
Calls superclass method QED::Reporter::Abstract#fail
# File lib/qed/reporter/linear.rb, line 46
def fail(step, assertion)
  super(step, assertion)

  print_step(step, 'FAIL', :red)

  #puts "FAIL".ansi(:red)

  s = []
  s << assertion.class.name
  s << assertion.message

  backtrace = sane_backtrace(assertion)
  backtrace.each do |bt|
    s << bt
    s << code_snippet(bt)
  end

  puts s.join("\n").tabto(8)
end
pass(step) click to toggle source
Calls superclass method QED::Reporter::Abstract#pass
# File lib/qed/reporter/linear.rb, line 35
def pass(step)
  super(step)

  print_step(step, 'PASS', :green)

  #s = []
  #s << "PASS".ansi(:green)
  #puts s.join("\n")
end

Private Instance Methods

post() click to toggle source
# File lib/qed/reporter/linear.rb, line 113
def post
  io.puts if @appendable
  @appendable = false
end
print(str) click to toggle source
print_step(step, stat, *color) click to toggle source
puts(str) click to toggle source
# File lib/qed/reporter/linear.rb, line 107
def puts(str)
  @appendable = false
  io.puts str
end
timestamp() click to toggle source
# File lib/qed/reporter/linear.rb, line 96
def timestamp
  (Time.now - @start_time).to_s[0,8]
end