jasmine-headless-webkit/vendor/assets/coffeescripts/jasmine.HeadlessReporter.Console.coffee

90 lines
2.3 KiB
CoffeeScript
Raw Normal View History

2011-12-12 17:22:32 +00:00
#= require jasmine.HeadlessReporter.js
#
class jasmine.HeadlessReporter.Console extends jasmine.HeadlessReporter
2011-10-27 00:05:05 +00:00
constructor: (@callback = null) ->
2011-12-12 17:22:32 +00:00
super(@callback)
@position = 0
@positions = "|/-\\"
2011-10-27 00:05:05 +00:00
reportRunnerResults: (runner) ->
2011-12-12 17:22:32 +00:00
super()
2011-10-27 00:05:05 +00:00
2011-12-29 23:37:23 +00:00
this.print("\n")
2011-10-27 00:05:05 +00:00
2011-12-12 17:22:32 +00:00
resultLine = this.formatResultLine(this._runtime())
2011-10-27 00:05:05 +00:00
if @failedCount == 0
2011-12-29 23:37:23 +00:00
this.puts("PASS: #{resultLine}".foreground('green'))
2011-10-27 00:05:05 +00:00
else
2011-12-29 23:37:23 +00:00
this.puts("FAIL: #{resultLine}".foreground('red'))
for result in @results
2011-12-29 23:37:23 +00:00
this.puts(result.toString())
2011-10-27 00:05:05 +00:00
2011-12-29 23:37:23 +00:00
this.puts("\nTest ordering seed: --seed #{JHW.getSeed()}")
2011-11-05 18:19:41 +00:00
2011-10-27 00:05:05 +00:00
reportRunnerStarting: (runner) ->
2011-12-12 17:22:32 +00:00
super(runner)
2011-12-29 23:37:23 +00:00
this.puts("\nRunning Jasmine specs...".bright()) if !this.hasError()
2011-10-27 00:05:05 +00:00
reportSpecResults: (spec) ->
2011-12-12 17:22:32 +00:00
super(spec)
this._reportSpecResult(spec, {
success: (results) =>
2011-12-29 23:37:23 +00:00
this.print('.'.foreground('green'))
2011-12-12 17:22:32 +00:00
failure: (results) =>
2011-12-29 23:37:23 +00:00
this.print('F'.foreground('red'))
2011-12-12 17:22:32 +00:00
failureResult = new HeadlessReporterResult(spec.getFullName(), spec.getSpecSplitName())
testCount = 1
for result in results.getItems()
if result.type == 'expect' and !result.passed_
if foundLine = result.expectations[testCount - 1]
[ result.line, result.lineNumber ] = foundLine
failureResult.addResult(result)
testCount += 1
@results.push(failureResult)
})
2011-10-27 00:05:05 +00:00
reportSpecWaiting: ->
if !@timer
@timer = true
2011-12-12 17:22:32 +00:00
@first = true
this._waitRunner()
reportSpecRunning: ->
if @timer
clearTimeout(@timer)
@timer = null
2011-12-29 23:37:23 +00:00
this.print(Intense.moveBack())
2011-12-12 17:22:32 +00:00
formatResultLine: (runtime) ->
2011-10-27 00:05:05 +00:00
line = []
line.push(@length)
line.push((if @length == 1 then "test" else "tests") + ',')
line.push(@failedCount)
line.push((if @failedCount == 1 then "failure" else "failures") + ',')
line.push(runtime)
line.push((if runtime == 1.0 then "sec" else "secs") + '.')
line.join(' ')
2011-12-12 17:22:32 +00:00
_waitRunner: =>
@timer = setTimeout(
=>
if @timer
2011-12-29 23:37:23 +00:00
this.print(Intense.moveBack()) if !@first
this.print(@positions.substr(@position, 1).foreground('yellow'))
2011-12-12 17:22:32 +00:00
@position += 1
@position %= @positions.length
@first = false
this._waitRunner()
, 750
)