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?
2011-06-13 12:14:24 +00:00
throw new Error("jasmine not laoded!")
2011-05-12 21:02:11 +00:00
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()
2011-06-08 17:47:51 +00:00
@length++
2011-05-16 02:42:02 +00:00
if results.passed()
2011-05-12 21:02:11 +00:00
JHW.specPassed()
else
JHW.specFailed()
2011-06-08 17:47:51 +00:00
@failedCount++
2011-05-12 21:02:11 +00:00
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_
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) ->