jasmine-headless-webkit/jasmine/jasmine.headless-reporter.coffee

45 lines
1.2 KiB
CoffeeScript
Raw Normal View History

2011-05-12 21:02:11 +00:00
if !jasmine?
throw new Exception("jasmine not laoded!")
class HeadlessReporterResult
constructor: (name) ->
@name = name
@results = []
2011-05-12 22:47:56 +00:00
addResult: (message) ->
@results.push(message)
2011-05-12 21:02:11 +00:00
print: ->
JHW.printName(@name)
for result in @results
do (result) =>
JHW.printResult(result)
class jasmine.HeadlessReporter
constructor: ->
@results = []
@failedCount = 0
@length = 0
reportRunnerResults: (runner) ->
for result in @results
do (result) =>
result.print()
2011-05-12 22:47:56 +00:00
JHW.finishSuite((new Date() - @startTime) / 1000.0, @length, @failedCount)
2011-05-12 21:02:11 +00:00
reportRunnerStarting: (runner) ->
2011-05-12 22:47:56 +00:00
@startTime = new Date()
2011-05-12 21:02:11 +00:00
reportSpecResults: (spec) ->
2011-05-16 02:42:02 +00:00
results = spec.results()
if results.passed()
2011-05-12 21:02:11 +00:00
JHW.specPassed()
else
JHW.specFailed()
failureResult = new HeadlessReporterResult(spec.getFullName())
2011-05-16 02:42:02 +00:00
for result in results.getItems()
2011-05-12 21:02:11 +00:00
do (result) =>
if result.type == 'expect' and !result.passed_
@failedCount += 1
2011-05-12 22:47:56 +00:00
failureResult.addResult(result.message)
2011-05-12 21:02:11 +00:00
@results.push(failureResult)
reportSpecStarting: (spec) ->
reportSuiteResults: (suite) ->
@length += suite.specs().length