jasmine-headless-webkit/vendor/assets/javascripts/jasmine.HeadlessReporter.Verbose.coffee

65 lines
1.4 KiB
CoffeeScript
Raw Normal View History

2012-01-10 22:14:37 +00:00
#= require jasmine.HeadlessReporter.ConsoleBase
#
class jasmine.HeadlessReporter.Verbose extends jasmine.HeadlessReporter.ConsoleBase
2012-01-12 21:47:36 +00:00
@prereport = false
2012-01-10 22:14:37 +00:00
displaySuccess: (spec) =>
this.displaySpec(spec, 'green')
displayFailure: (spec) =>
this.displaySpec(spec, 'red')
displaySpec: (spec, color) =>
currentLastNames = (@lastNames || []).slice(0)
@lastNames = spec.getSpecSplitName()
2012-01-11 19:24:09 +00:00
for line in this.indentSpec(@lastNames, currentLastNames, color)
if line? and !_.isEmpty(line)
this.puts(line)
2012-01-10 22:14:37 +00:00
indentSpec: (current, last, color) =>
last = last.slice(0)
2012-01-11 16:37:25 +00:00
lines = []
2012-01-10 22:14:37 +00:00
for name in current
2012-01-11 16:37:25 +00:00
if last.shift() != name
lines.push(name)
else
lines.push(null)
this.indentLines(lines, color)
indentLines: (lines, color) =>
indent = ''
output = []
for line in lines
if line?
outputLine = indent
outputLine += this.colorLine(line, color)
output.push(outputLine)
2012-01-10 22:14:37 +00:00
indent += ' '
output
2012-01-11 16:37:25 +00:00
colorLine: (line, color) =>
line.foreground(color)
2012-01-11 20:41:27 +00:00
2012-01-12 21:47:36 +00:00
reportSpecStarting: (spec) =>
if jasmine.HeadlessReporter.Verbose.prereport
this.puts(spec.getSpecSplitName().join(' '))
2012-01-11 20:41:27 +00:00
reportException: (e) =>
e = JHW.createCoffeeScriptFileException(e)
2012-01-12 21:47:36 +00:00
2012-01-11 20:41:27 +00:00
if e.sourceURL && e.lineNumber
2012-01-12 21:47:36 +00:00
output = "#{e.sourceURL}:#{e.lineNumber} #{e.message}"
else
output = e.message ? e
2012-01-11 20:41:27 +00:00
this.puts(output.foreground('yellow'))