dwf: made Jasmine & Jasmine.Reporters namespaces; the instance of Jasmine is now just jasmine.
This commit is contained in:
+42
-26
@@ -152,17 +152,35 @@ var queuedFunction = function(func, timeout, spec) {
|
||||
* Jasmine
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
var Jasmine = {}
|
||||
|
||||
Jasmine.init = function () {
|
||||
var that = {
|
||||
currentSpec: null,
|
||||
currentSuite: null,
|
||||
currentRunner: null,
|
||||
execute: function () {
|
||||
that.currentRunner.execute();
|
||||
}
|
||||
}
|
||||
return that;
|
||||
}
|
||||
|
||||
var jasmine = Jasmine.init();
|
||||
|
||||
/*
|
||||
* Matchers methods; add your own with Matchers.method()
|
||||
* Jasmine.Matchers methods; add your own with Jasmine.Matchers.method() - don't forget to write a test
|
||||
*
|
||||
*/
|
||||
|
||||
Matchers = function (actual, results) {
|
||||
Jasmine.Matchers = function (actual, results) {
|
||||
this.actual = actual;
|
||||
this.passing_message = 'Passed.'
|
||||
this.results = results || nestedResults();
|
||||
}
|
||||
|
||||
Matchers.method('report', function (result, failing_message) {
|
||||
Jasmine.Matchers.method('report', function (result, failing_message) {
|
||||
|
||||
this.results.push({
|
||||
passed: result,
|
||||
@@ -172,12 +190,12 @@ Matchers.method('report', function (result, failing_message) {
|
||||
return result;
|
||||
});
|
||||
|
||||
Matchers.method('should_equal', function (expected) {
|
||||
Jasmine.Matchers.method('should_equal', function (expected) {
|
||||
return this.report((this.actual === expected),
|
||||
'Expected ' + expected + ' but got ' + this.actual + '.');
|
||||
});
|
||||
|
||||
Matchers.method('should_not_equal', function (expected) {
|
||||
Jasmine.Matchers.method('should_not_equal', function (expected) {
|
||||
return this.report((this.actual !== expected),
|
||||
'Expected ' + expected + ' to not equal ' + this.actual + ', but it does.');
|
||||
});
|
||||
@@ -196,7 +214,7 @@ var it = function (description, func) {
|
||||
results: nestedResults(),
|
||||
|
||||
expects_that: function (actual) {
|
||||
return new Matchers(actual, that.results);
|
||||
return new Jasmine.Matchers(actual, that.results);
|
||||
},
|
||||
|
||||
waits: function (timeout) {
|
||||
@@ -209,8 +227,8 @@ var it = function (description, func) {
|
||||
},
|
||||
|
||||
finishCallback: function () {
|
||||
if (Jasmine.reporter) {
|
||||
Jasmine.reporter.reportSpecResults(that.results);
|
||||
if (jasmine.reporter) {
|
||||
jasmine.reporter.reportSpecResults(that.results);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -243,8 +261,8 @@ var it = function (description, func) {
|
||||
|
||||
that.runs = addToQueue;
|
||||
|
||||
currentSuite.specs.push(that);
|
||||
currentSpec = that;
|
||||
jasmine.currentSuite.specs.push(that);
|
||||
jasmine.currentSpec = that;
|
||||
|
||||
if (func) {
|
||||
func();
|
||||
@@ -255,19 +273,19 @@ var it = function (description, func) {
|
||||
}
|
||||
|
||||
var runs = function (func) {
|
||||
currentSpec.runs(func);
|
||||
jasmine.currentSpec.runs(func);
|
||||
}
|
||||
|
||||
var waits = function (timeout) {
|
||||
currentSpec.waits(timeout);
|
||||
jasmine.currentSpec.waits(timeout);
|
||||
}
|
||||
|
||||
var beforeEach = function (beforeEach) {
|
||||
currentSuite.beforeEach = beforeEach;
|
||||
jasmine.currentSuite.beforeEach = beforeEach;
|
||||
}
|
||||
|
||||
var afterEach = function (afterEach) {
|
||||
currentSuite.afterEach = afterEach;
|
||||
jasmine.currentSuite.afterEach = afterEach;
|
||||
}
|
||||
|
||||
var describe = function (description, spec_definitions) {
|
||||
@@ -276,16 +294,16 @@ var describe = function (description, spec_definitions) {
|
||||
that.description = description;
|
||||
that.specs = that.actions;
|
||||
|
||||
currentSuite = that;
|
||||
Jasmine.suites.push(that);
|
||||
jasmine.currentSuite = that;
|
||||
jasmine.currentRunner.suites.push(that);
|
||||
|
||||
spec_definitions();
|
||||
|
||||
that.results.description = description;
|
||||
|
||||
that.finishCallback = function () {
|
||||
if (Jasmine.reporter) {
|
||||
Jasmine.reporter.reportSuiteResults(that.results);
|
||||
if (jasmine.reporter) {
|
||||
jasmine.reporter.reportSuiteResults(that.results);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -299,26 +317,24 @@ var Runner = function () {
|
||||
that.results.description = 'All Jasmine Suites';
|
||||
|
||||
that.finishCallback = function () {
|
||||
if (that.reporter) {
|
||||
that.reporter.reportRunnerResults(that.results);
|
||||
if (jasmine.reporter) {
|
||||
jasmine.reporter.reportRunnerResults(that.results);
|
||||
}
|
||||
}
|
||||
|
||||
Jasmine = that;
|
||||
jasmine.currentRunner = that;
|
||||
return that;
|
||||
}
|
||||
|
||||
var Jasmine = Runner();
|
||||
var currentSuite;
|
||||
var currentSpec;
|
||||
jasmine.currentRunner = Runner();
|
||||
|
||||
/* JasmineReporters.reporter
|
||||
* Base object that will get called whenever a Spec, Suite, or Runner is done. It is up to
|
||||
* descendants of this object to do something with the results (see json_reporter.js)
|
||||
*/
|
||||
var JasmineReporters = {};
|
||||
Jasmine.Reporters = {};
|
||||
|
||||
JasmineReporters.reporter = function (callbacks) {
|
||||
Jasmine.Reporters.reporter = function (callbacks) {
|
||||
var that = {
|
||||
callbacks: callbacks || {},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user