Class: BareTest::Formatter::Vows

Inherits:
BareTest::Formatter show all
Defined in:
lib/baretest/formatter/vows.rb

Constant Summary collapse

Symbols =
{
  :success => '✓',
  :skipped => '-',
  :pending => '-',
  :failure => '✗',
  :error   => '✗'
}
Labels =
{
  :success => "\e[1;32mOK\e[0m",
  :pending => "\e[1;96mPending\e[0m",
  :failure => "\e[1;31mBroken\e[0m",
  :error   => "\e[1;31mBroken\e[0m"
}
Colors =
{
  :success => "\e[32m",
  :skipped => "\e[30m",
  :pending => "\e[36m",
  :failure => "\e[31m",
  :error   => "\e[31m",
  :normal  => "\e[0m"
}

Instance Method Summary collapse

Instance Method Details

#end_all(status_collection, elapsed) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/baretest/formatter/vows.rb', line 61

def end_all status_collection, elapsed
  success, pending, skipped,
  failure, error = *status_collection.values_at(:success,
                                                :pending,
                                                :skipped,
                                                :failure,
                                                :error)

  status = Symbols[status_collection.code] +
  ' ' + Labels[status_collection.code]
  status += " » \e[1m#{success}\e[0m honored" if success > 0
  status += " • \e[1m#{pending}\e[0m pending" if pending > 0
  status += " • \e[1m#{skipped}\e[0m skipped" if skipped > 0
  status += " • \e[1m#{failure}\e[0m failed"  if failure > 0
  status += " • \e[1m#{error}\e[0m broken"    if error   > 0
  status += " \e[30m(#{elapsed}s)\e[0m"

  puts status
end

#end_test(test, status, elapsed) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/baretest/formatter/vows.rb', line 44

def end_test test, status, elapsed
  apply_deferred

  puts indent(test, -1) + Symbols[status.code] +
  ' ' + stylize(status.code, test.description)

  case status.code
    when :pending, :skipped, :failure
      puts indent(test) + '» ' + stylize(status.code, status.reason)
    when :error
      backtrace = backtrace(status).join("\n")

      puts indent(test) + '» ' + stylize(status.code, status.reason)
      puts indent(test) + '» ' + stylize(status.code, backtrace)
  end
end

#start_suite(suite) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/baretest/formatter/vows.rb', line 36

def start_suite suite
  defer do
    if suite.description
      puts indent(suite, -1) + suite.description
    end
  end
end

#stylize(status, string) ⇒ Object



32
33
34
# File 'lib/baretest/formatter/vows.rb', line 32

def stylize status, string
  Colors[status] + string + Colors[:normal]
end