2008-12-08 19:35:10 +00:00
|
|
|
/*
|
2009-05-29 03:02:15 +00:00
|
|
|
* jasmine.Reporters.JSON --
|
2008-12-08 19:35:10 +00:00
|
|
|
* Basic reporter that keeps a JSON string of the most recent Spec, Suite or Runner
|
|
|
|
* result. Calling application can then do whatever it wants/needs with the string;
|
|
|
|
*/
|
2009-05-29 03:02:15 +00:00
|
|
|
jasmine.Reporters.JSON = function () {
|
2009-03-01 13:34:00 +00:00
|
|
|
var toJSON = function(object){
|
|
|
|
return JSON.stringify(object);
|
|
|
|
};
|
2009-05-29 03:02:15 +00:00
|
|
|
var that = jasmine.Reporters.reporter();
|
2008-12-08 19:35:10 +00:00
|
|
|
that.specJSON = '';
|
|
|
|
that.suiteJSON = '';
|
|
|
|
that.runnerJSON = '';
|
2008-12-04 20:54:54 +00:00
|
|
|
|
2009-05-29 03:02:15 +00:00
|
|
|
var saveSpecResults = function (spec) {
|
|
|
|
that.specJSON = toJSON(spec.getResults());
|
2009-03-01 13:34:00 +00:00
|
|
|
};
|
2008-12-08 19:35:10 +00:00
|
|
|
that.reportSpecResults = saveSpecResults;
|
2008-12-06 01:33:35 +00:00
|
|
|
|
2009-05-29 03:02:15 +00:00
|
|
|
var saveSuiteResults = function (suite) {
|
|
|
|
that.suiteJSON = toJSON(suite.getResults());
|
2009-03-01 13:34:00 +00:00
|
|
|
};
|
2008-12-08 19:35:10 +00:00
|
|
|
that.reportSuiteResults = saveSuiteResults;
|
|
|
|
|
2009-05-29 03:02:15 +00:00
|
|
|
var saveRunnerResults = function (runner) {
|
|
|
|
that.runnerJSON = toJSON(runner.getResults());
|
2009-03-01 13:34:00 +00:00
|
|
|
};
|
2008-12-08 19:35:10 +00:00
|
|
|
that.reportRunnerResults = saveRunnerResults;
|
2009-05-29 03:02:15 +00:00
|
|
|
this.log = function (str) {
|
|
|
|
console.log(str);
|
2008-12-08 19:35:10 +00:00
|
|
|
};
|
|
|
|
|
2009-05-29 03:02:15 +00:00
|
|
|
that.toJSON = toJSON;
|
2008-12-08 19:35:10 +00:00
|
|
|
return that;
|
2009-03-01 13:34:00 +00:00
|
|
|
};
|