diff --git a/doc/files.html b/doc/files.html index bce9c40..dfdecfe 100644 --- a/doc/files.html +++ b/doc/files.html @@ -454,7 +454,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Nov 10 2009 17:31:30 GMT-0500 (EST) + Documentation generated by JsDoc Toolkit 2.1.0 on Wed Dec 23 2009 21:27:32 GMT-0800 (PST)
\ No newline at end of file diff --git a/doc/index.html b/doc/index.html index 2f8b49a..fa86084 100644 --- a/doc/index.html +++ b/doc/index.html @@ -316,7 +316,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Nov 10 2009 17:31:30 GMT-0500 (EST) + Documentation generated by JsDoc Toolkit 2.1.0 on Wed Dec 23 2009 21:27:32 GMT-0800 (PST)
\ No newline at end of file diff --git a/doc/symbols/_global_.html b/doc/symbols/_global_.html index 2b25eed..57f29d3 100644 --- a/doc/symbols/_global_.html +++ b/doc/symbols/_global_.html @@ -912,7 +912,7 @@ A convenience method that allows existing specs to be disabled temporarily durin
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Nov 10 2009 17:31:29 GMT-0500 (EST) + Documentation generated by JsDoc Toolkit 2.1.0 on Wed Dec 23 2009 21:27:32 GMT-0800 (PST)
diff --git a/doc/symbols/jasmine.Block.html b/doc/symbols/jasmine.Block.html index f50be43..a04e2c9 100644 --- a/doc/symbols/jasmine.Block.html +++ b/doc/symbols/jasmine.Block.html @@ -411,7 +411,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Nov 10 2009 17:31:29 GMT-0500 (EST) + Documentation generated by JsDoc Toolkit 2.1.0 on Wed Dec 23 2009 21:27:32 GMT-0800 (PST)
diff --git a/doc/symbols/jasmine.Clock.html b/doc/symbols/jasmine.Clock.html index dbe6f6a..fd7c165 100644 --- a/doc/symbols/jasmine.Clock.html +++ b/doc/symbols/jasmine.Clock.html @@ -672,7 +672,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Nov 10 2009 17:31:29 GMT-0500 (EST) + Documentation generated by JsDoc Toolkit 2.1.0 on Wed Dec 23 2009 21:27:32 GMT-0800 (PST)
diff --git a/doc/symbols/jasmine.Env.html b/doc/symbols/jasmine.Env.html index ac69aa9..40efbdd 100644 --- a/doc/symbols/jasmine.Env.html +++ b/doc/symbols/jasmine.Env.html @@ -382,6 +382,15 @@ ul.inheritsList + +   + +
matchersClass() +
+
+ + +   @@ -910,6 +919,31 @@ ul.inheritsList +
+ + +
+ + + matchersClass() + +
+
+ + + +
+ + + + + + + + + + +
@@ -1129,7 +1163,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Nov 10 2009 17:31:29 GMT-0500 (EST) + Documentation generated by JsDoc Toolkit 2.1.0 on Wed Dec 23 2009 21:27:32 GMT-0800 (PST)
diff --git a/doc/symbols/jasmine.JsApiReporter.html b/doc/symbols/jasmine.JsApiReporter.html index 38ea39f..ca02c07 100644 --- a/doc/symbols/jasmine.JsApiReporter.html +++ b/doc/symbols/jasmine.JsApiReporter.html @@ -816,7 +816,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Nov 10 2009 17:31:30 GMT-0500 (EST) + Documentation generated by JsDoc Toolkit 2.1.0 on Wed Dec 23 2009 21:27:32 GMT-0800 (PST)
diff --git a/doc/symbols/jasmine.Matchers.html b/doc/symbols/jasmine.Matchers.html index 6aa15b3..4ec8408 100644 --- a/doc/symbols/jasmine.Matchers.html +++ b/doc/symbols/jasmine.Matchers.html @@ -268,184 +268,6 @@ ul.inheritsList - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Field Summary
Field AttributesField Name and Description
  -
- toBe -
-
toBe: compares the actual to the expected using ===
-
  - -
Matcher that compares the acutal to undefined.
-
  -
- toBeFalsy -
-
Matcher that boolean nots the actual.
-
  -
- toBeNull -
-
Matcher that compares the actual to null.
-
  - -
Matcher that boolean not-nots the actual.
-
  - -
Matcher that compares the acutal to undefined.
-
  -
- toContain -
-
Matcher that checks that the expected item is an element in the actual Array.
-
  -
- toEqual -
-
toEqual: compares the actual to the expected using common sense equality.
-
  -
- toMatch -
-
Matcher that compares the actual to the expected using a regular expression.
-
  -
- toNotBe -
-
toNotBe: compares the actual to the expected using !==
-
  - -
Matcher that checks that the expected item is NOT an element in the actual Array.
-
  - -
toNotEqual: compares the actual to the expected using the ! of jasmine.Matchers.toEqual
-
  - -
Matcher that compares the actual to the expected using the boolean inverse of jasmine.Matchers.toMatch
-
  -
- toThrow -
-
Matcher that checks that the expected exception was thrown by the actual.
-
  -
- wasCalled -
-
Matcher that checks to see if the acutal, a Jasmine spy, was called.
-
  - -
Matcher that checks to see if the acutal, a Jasmine spy, was not called.
-
- - - - @@ -473,7 +295,16 @@ ul.inheritsList <static>   -
jasmine.Matchers.matcherFn_(matcherName, options) +
jasmine.Matchers.matcherFn_(matcherName, matcherFunction) +
+
+ + + + +   + +
message(expected)
@@ -497,6 +328,186 @@ ul.inheritsList + +   + +
toBe(expected) +
+
toBe: compares the actual to the expected using ===
+ + + + +   + +
toBeDefined() +
+
Matcher that compares the actual to jasmine.undefined.
+ + + + +   + +
toBeFalsy() +
+
Matcher that boolean nots the actual.
+ + + + +   + +
toBeGreaterThan(expected) +
+
+ + + + +   + +
toBeLessThan(expected) +
+
+ + + + +   + +
toBeNull() +
+
Matcher that compares the actual to null.
+ + + + +   + +
toBeTruthy() +
+
Matcher that boolean not-nots the actual.
+ + + + +   + +
toBeUndefined() +
+
Matcher that compares the actual to jasmine.undefined.
+ + + + +   + +
toContain(item) +
+
Matcher that checks that the expected item is an element in the actual Array.
+ + + + +   + +
toEqual(expected) +
+
toEqual: compares the actual to the expected using common sense equality.
+ + + + +   + +
toMatch(reg_exp) +
+
Matcher that compares the actual to the expected using a regular expression.
+ + + + +   + +
toNotBe(expected) +
+
toNotBe: compares the actual to the expected using !==
+ + + + +   + +
toNotContain(item) +
+
Matcher that checks that the expected item is NOT an element in the actual Array.
+ + + + +   + +
toNotEqual(expected) +
+
toNotEqual: compares the actual to the expected using the ! of jasmine.Matchers.toEqual
+ + + + +   + +
toNotMatch(reg_exp) +
+
Matcher that compares the actual to the expected using the boolean inverse of jasmine.Matchers.toMatch
+ + + + +   + +
toThrow(expectedException) +
+
Matcher that checks that the expected exception was thrown by the actual.
+ + + + +   + +
wasCalled() +
+
Matcher that checks to see if the actual, a Jasmine spy, was called.
+ + + + +   + +
wasCalledWith() +
+
Matcher that checks to see if the actual, a Jasmine spy, was called with a set of parameters.
+ + + + +   + +
wasNotCalled() +
+
Matcher that checks to see if the actual, a Jasmine spy, was not called.
+ + + + +   + +
wasNotCalledWith() +
+
+ + + @@ -561,364 +572,6 @@ ul.inheritsList -
- Field Detail -
- - -
- - - toBe - -
-
- toBe: compares the actual to the expected using === - - -
- - - - - - - - -
- - -
- - - toBeDefined - -
-
- Matcher that compares the acutal to undefined. - - -
- - - - - - - - -
- - -
- - - toBeFalsy - -
-
- Matcher that boolean nots the actual. - - -
- - - - - - - - -
- - -
- - - toBeNull - -
-
- Matcher that compares the actual to null. - - -
- - - - - - - - -
- - -
- - - toBeTruthy - -
-
- Matcher that boolean not-nots the actual. - - -
- - - - - - - - -
- - -
- - - toBeUndefined - -
-
- Matcher that compares the acutal to undefined. - - -
- - - - - - - - -
- - -
- - - toContain - -
-
- Matcher that checks that the expected item is an element in the actual Array. - - -
- - - - - - - - -
- - -
- - - toEqual - -
-
- toEqual: compares the actual to the expected using common sense equality. Handles Objects, Arrays, etc. - - -
- - - - - - - - -
- - -
- - - toMatch - -
-
- Matcher that compares the actual to the expected using a regular expression. Constructs a RegExp, so takes -a pattern or a String. - - -
- - - - - - - - -
- - -
- - - toNotBe - -
-
- toNotBe: compares the actual to the expected using !== - - -
- - - - - - - - -
- - -
- - - toNotContain - -
-
- Matcher that checks that the expected item is NOT an element in the actual Array. - - -
- - - - - - - - -
- - -
- - - toNotEqual - -
-
- toNotEqual: compares the actual to the expected using the ! of jasmine.Matchers.toEqual - - -
- - - - - - - - -
- - -
- - - toNotMatch - -
-
- Matcher that compares the actual to the expected using the boolean inverse of jasmine.Matchers.toMatch - - -
- - - - - - - - -
- - -
- - - toThrow - -
-
- Matcher that checks that the expected exception was thrown by the actual. - - -
- - - - - - - - -
- - -
- - - wasCalled - -
-
- Matcher that checks to see if the acutal, a Jasmine spy, was called. - - -
- - - - - - - - -
- - -
- - - wasNotCalled - -
-
- Matcher that checks to see if the acutal, a Jasmine spy, was not called. - - -
- - - - - - - - - - - @@ -966,7 +619,7 @@ a pattern or a String.
<static> - jasmine.Matchers.matcherFn_(matcherName, options) + jasmine.Matchers.matcherFn_(matcherName, matcherFunction)
@@ -988,7 +641,43 @@ a pattern or a String.
- options + matcherFunction + +
+
+ + + + + + + + + + +
+ + +
+ + + message(expected) + +
+
+ + + +
+ + + + +
+
Parameters:
+ +
+ expected
@@ -1086,6 +775,632 @@ a pattern or a String. +
+ + +
+ + + toBe(expected) + +
+
+ toBe: compares the actual to the expected using === + + +
+ + + + +
+
Parameters:
+ +
+ expected + +
+
+ +
+ + + + + + + + +
+ + +
+ + + toBeDefined() + +
+
+ Matcher that compares the actual to jasmine.undefined. + + +
+ + + + + + + + + + + +
+ + +
+ + + toBeFalsy() + +
+
+ Matcher that boolean nots the actual. + + +
+ + + + + + + + + + + +
+ + +
+ + + toBeGreaterThan(expected) + +
+
+ + + +
+ + + + +
+
Parameters:
+ +
+ expected + +
+
+ +
+ + + + + + + + +
+ + +
+ + + toBeLessThan(expected) + +
+
+ + + +
+ + + + +
+
Parameters:
+ +
+ expected + +
+
+ +
+ + + + + + + + +
+ + +
+ + + toBeNull() + +
+
+ Matcher that compares the actual to null. + + +
+ + + + + + + + + + + +
+ + +
+ + + toBeTruthy() + +
+
+ Matcher that boolean not-nots the actual. + + +
+ + + + + + + + + + + +
+ + +
+ + + toBeUndefined() + +
+
+ Matcher that compares the actual to jasmine.undefined. + + +
+ + + + + + + + + + + +
+ + +
+ + + toContain(item) + +
+
+ Matcher that checks that the expected item is an element in the actual Array. + + +
+ + + + +
+
Parameters:
+ +
+ {Object} item + +
+
+ +
+ + + + + + + + +
+ + +
+ + + toEqual(expected) + +
+
+ toEqual: compares the actual to the expected using common sense equality. Handles Objects, Arrays, etc. + + +
+ + + + +
+
Parameters:
+ +
+ expected + +
+
+ +
+ + + + + + + + +
+ + +
+ + + toMatch(reg_exp) + +
+
+ Matcher that compares the actual to the expected using a regular expression. Constructs a RegExp, so takes +a pattern or a String. + + +
+ + + + +
+
Parameters:
+ +
+ reg_exp + +
+
+ +
+ + + + + + + + +
+ + +
+ + + toNotBe(expected) + +
+
+ toNotBe: compares the actual to the expected using !== + + +
+ + + + +
+
Parameters:
+ +
+ expected + +
+
+ +
+ + + + + + + + +
+ + +
+ + + toNotContain(item) + +
+
+ Matcher that checks that the expected item is NOT an element in the actual Array. + + +
+ + + + +
+
Parameters:
+ +
+ {Object} item + +
+
+ +
+ + + + + + + + +
+ + +
+ + + toNotEqual(expected) + +
+
+ toNotEqual: compares the actual to the expected using the ! of jasmine.Matchers.toEqual + + +
+ + + + +
+
Parameters:
+ +
+ expected + +
+
+ +
+ + + + + + + + +
+ + +
+ + + toNotMatch(reg_exp) + +
+
+ Matcher that compares the actual to the expected using the boolean inverse of jasmine.Matchers.toMatch + + +
+ + + + +
+
Parameters:
+ +
+ reg_exp + +
+
+ +
+ + + + + + + + +
+ + +
+ + + toThrow(expectedException) + +
+
+ Matcher that checks that the expected exception was thrown by the actual. + + +
+ + + + +
+
Parameters:
+ +
+ {String} expectedException + +
+
+ +
+ + + + + + + + +
+ + +
+ + + wasCalled() + +
+
+ Matcher that checks to see if the actual, a Jasmine spy, was called. + + +
+ + + + + + + + + + + +
+ + +
+ + + wasCalledWith() + +
+
+ Matcher that checks to see if the actual, a Jasmine spy, was called with a set of parameters. + + +
+ + + +

+					
+					
+					
+						
+						
+						
+						
+						
+						
+						
+
+					
+ + +
+ + + wasNotCalled() + +
+
+ Matcher that checks to see if the actual, a Jasmine spy, was not called. + + +
+ + + + + + + + + + + +
+ + +
+ + + wasNotCalledWith() + +
+
+ + + +
+ + + + + + + + + + + @@ -1100,7 +1415,7 @@ a pattern or a String.
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Nov 10 2009 17:31:30 GMT-0500 (EST) + Documentation generated by JsDoc Toolkit 2.1.0 on Wed Dec 23 2009 21:27:32 GMT-0800 (PST)
diff --git a/doc/symbols/jasmine.MultiReporter.html b/doc/symbols/jasmine.MultiReporter.html index b2ead53..8583a03 100644 --- a/doc/symbols/jasmine.MultiReporter.html +++ b/doc/symbols/jasmine.MultiReporter.html @@ -388,7 +388,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Nov 10 2009 17:31:30 GMT-0500 (EST) + Documentation generated by JsDoc Toolkit 2.1.0 on Wed Dec 23 2009 21:27:32 GMT-0800 (PST)
diff --git a/doc/symbols/jasmine.NestedResults.html b/doc/symbols/jasmine.NestedResults.html index 69283a6..395225e 100644 --- a/doc/symbols/jasmine.NestedResults.html +++ b/doc/symbols/jasmine.NestedResults.html @@ -704,7 +704,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Nov 10 2009 17:31:30 GMT-0500 (EST) + Documentation generated by JsDoc Toolkit 2.1.0 on Wed Dec 23 2009 21:27:32 GMT-0800 (PST)
diff --git a/doc/symbols/jasmine.Reporter.html b/doc/symbols/jasmine.Reporter.html index d035c63..3646e49 100644 --- a/doc/symbols/jasmine.Reporter.html +++ b/doc/symbols/jasmine.Reporter.html @@ -568,7 +568,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Nov 10 2009 17:31:30 GMT-0500 (EST) + Documentation generated by JsDoc Toolkit 2.1.0 on Wed Dec 23 2009 21:27:32 GMT-0800 (PST)
diff --git a/doc/symbols/jasmine.Runner.html b/doc/symbols/jasmine.Runner.html index c726687..c3ac98a 100644 --- a/doc/symbols/jasmine.Runner.html +++ b/doc/symbols/jasmine.Runner.html @@ -704,7 +704,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Nov 10 2009 17:31:30 GMT-0500 (EST) + Documentation generated by JsDoc Toolkit 2.1.0 on Wed Dec 23 2009 21:27:32 GMT-0800 (PST)
diff --git a/doc/symbols/jasmine.Spec.html b/doc/symbols/jasmine.Spec.html index bc5e538..3c6473c 100644 --- a/doc/symbols/jasmine.Spec.html +++ b/doc/symbols/jasmine.Spec.html @@ -1253,7 +1253,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Nov 10 2009 17:31:30 GMT-0500 (EST) + Documentation generated by JsDoc Toolkit 2.1.0 on Wed Dec 23 2009 21:27:32 GMT-0800 (PST)
diff --git a/doc/symbols/jasmine.Spy.html b/doc/symbols/jasmine.Spy.html index a7f98a6..0cb83ac 100644 --- a/doc/symbols/jasmine.Spy.html +++ b/doc/symbols/jasmine.Spy.html @@ -849,7 +849,7 @@ expect(foo.bar.callCount).toEqual(0);
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Nov 10 2009 17:31:30 GMT-0500 (EST) + Documentation generated by JsDoc Toolkit 2.1.0 on Wed Dec 23 2009 21:27:32 GMT-0800 (PST)
diff --git a/doc/symbols/jasmine.Suite.html b/doc/symbols/jasmine.Suite.html index 898ace0..d5f40c6 100644 --- a/doc/symbols/jasmine.Suite.html +++ b/doc/symbols/jasmine.Suite.html @@ -699,7 +699,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Nov 10 2009 17:31:30 GMT-0500 (EST) + Documentation generated by JsDoc Toolkit 2.1.0 on Wed Dec 23 2009 21:27:32 GMT-0800 (PST)
diff --git a/doc/symbols/jasmine.html b/doc/symbols/jasmine.html index 14b52e6..835bd0f 100644 --- a/doc/symbols/jasmine.html +++ b/doc/symbols/jasmine.html @@ -405,6 +405,15 @@ Jasmine environment.
+ + <static>   + +
jasmine.isSpy(putativeSpy) +
+
Determines whether an object is a spy.
+ + + <static>   @@ -486,15 +495,6 @@ Jasmine environment.
- - <static>   - -
jasmine.XmlHttpRequest() -
-
- - - @@ -909,6 +909,49 @@ Jasmine environment. +
+
Returns:
+ +
{Boolean}
+ +
+ + + + +
+ + +
<static> + + {Boolean} + jasmine.isSpy(putativeSpy) + +
+
+ Determines whether an object is a spy. + + +
+ + + + +
+
Parameters:
+ +
+ {jasmine.Spy|Object} putativeSpy + +
+
+ +
+ + + + +
Returns:
@@ -1282,31 +1325,6 @@ Jasmine environment. -
- - -
<static> - - - jasmine.XmlHttpRequest() - -
-
- - - -
- - - - - - - - - - - @@ -1321,7 +1339,7 @@ Jasmine environment.
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Nov 10 2009 17:31:29 GMT-0500 (EST) + Documentation generated by JsDoc Toolkit 2.1.0 on Wed Dec 23 2009 21:27:32 GMT-0800 (PST)
diff --git a/doc/symbols/jasmine.util.html b/doc/symbols/jasmine.util.html index 905d878..bb10c02 100644 --- a/doc/symbols/jasmine.util.html +++ b/doc/symbols/jasmine.util.html @@ -529,7 +529,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Nov 10 2009 17:31:30 GMT-0500 (EST) + Documentation generated by JsDoc Toolkit 2.1.0 on Wed Dec 23 2009 21:27:32 GMT-0800 (PST)
diff --git a/doc/symbols/src/lib_TrivialReporter.js.html b/doc/symbols/src/lib_TrivialReporter.js.html index df0b881..9eac326 100644 --- a/doc/symbols/src/lib_TrivialReporter.js.html +++ b/doc/symbols/src/lib_TrivialReporter.js.html @@ -96,31 +96,29 @@ 89 for (var i = 0; i < resultItems.length; i++) { 90 var result = resultItems[i]; 91 if (result.passed && !result.passed()) { - 92 var resultMessageDiv = this.createDom('div', {className: 'resultMessage fail'}); - 93 resultMessageDiv.innerHTML = result.message; // todo: lame; mend - 94 specDiv.appendChild(resultMessageDiv); - 95 specDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack)); - 96 } - 97 } - 98 this.suiteDivs[spec.suite.getFullName()].appendChild(specDiv); - 99 }; -100 -101 jasmine.TrivialReporter.prototype.log = function() { -102 console.log.apply(console, arguments); -103 }; -104 -105 jasmine.TrivialReporter.prototype.getLocation = function() { -106 return this.document.location; -107 }; -108 -109 jasmine.TrivialReporter.prototype.specFilter = function(spec) { -110 var paramMap = {}; -111 var params = this.getLocation().search.substring(1).split('&'); -112 for (var i = 0; i < params.length; i++) { -113 var p = params[i].split('='); -114 paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]); -115 } -116 -117 if (!paramMap["spec"]) return true; -118 return spec.getFullName().indexOf(paramMap["spec"]) == 0; -119 }; \ No newline at end of file + 92 specDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message)); + 93 specDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack)); + 94 } + 95 } + 96 this.suiteDivs[spec.suite.getFullName()].appendChild(specDiv); + 97 }; + 98 + 99 jasmine.TrivialReporter.prototype.log = function() { +100 console.log.apply(console, arguments); +101 }; +102 +103 jasmine.TrivialReporter.prototype.getLocation = function() { +104 return this.document.location; +105 }; +106 +107 jasmine.TrivialReporter.prototype.specFilter = function(spec) { +108 var paramMap = {}; +109 var params = this.getLocation().search.substring(1).split('&'); +110 for (var i = 0; i < params.length; i++) { +111 var p = params[i].split('='); +112 paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]); +113 } +114 +115 if (!paramMap["spec"]) return true; +116 return spec.getFullName().indexOf(paramMap["spec"]) == 0; +117 }; \ No newline at end of file diff --git a/doc/symbols/src/src_Env.js.html b/doc/symbols/src/src_Env.js.html index e004986..7b46e68 100644 --- a/doc/symbols/src/src_Env.js.html +++ b/doc/symbols/src/src_Env.js.html @@ -17,7 +17,7 @@ 10 11 this.reporter = new jasmine.MultiReporter(); 12 - 13 this.updateInterval = jasmine.DEFAULT_UPDATE_INTERVAL + 13 this.updateInterval = jasmine.DEFAULT_UPDATE_INTERVAL; 14 this.lastUpdate = 0; 15 this.specFilter = function() { 16 return true; @@ -26,207 +26,218 @@ 19 this.nextSpecId_ = 0; 20 this.nextSuiteId_ = 0; 21 this.equalityTesters_ = []; - 22 }; - 23 - 24 - 25 jasmine.Env.prototype.setTimeout = jasmine.setTimeout; - 26 jasmine.Env.prototype.clearTimeout = jasmine.clearTimeout; - 27 jasmine.Env.prototype.setInterval = jasmine.setInterval; - 28 jasmine.Env.prototype.clearInterval = jasmine.clearInterval; - 29 - 30 /** - 31 * @returns an object containing jasmine version build info, if set. - 32 */ - 33 jasmine.Env.prototype.version = function () { - 34 if (jasmine.version_) { - 35 return jasmine.version_; - 36 } else { - 37 throw new Error('Version not set'); - 38 } - 39 }; + 22 + 23 // wrap matchers + 24 this.matchersClass = function() { + 25 jasmine.Matchers.apply(this, arguments); + 26 }; + 27 jasmine.util.inherit(this.matchersClass, jasmine.Matchers); + 28 + 29 for (var methodName in jasmine.Matchers.prototype) { + 30 var orig = jasmine.Matchers.prototype[methodName]; + 31 this.matchersClass.prototype[methodName] = jasmine.Matchers.matcherFn_(methodName, orig); + 32 } + 33 }; + 34 + 35 + 36 jasmine.Env.prototype.setTimeout = jasmine.setTimeout; + 37 jasmine.Env.prototype.clearTimeout = jasmine.clearTimeout; + 38 jasmine.Env.prototype.setInterval = jasmine.setInterval; + 39 jasmine.Env.prototype.clearInterval = jasmine.clearInterval; 40 41 /** - 42 * @returns a sequential integer starting at 0 + 42 * @returns an object containing jasmine version build info, if set. 43 */ - 44 jasmine.Env.prototype.nextSpecId = function () { - 45 return this.nextSpecId_++; - 46 }; - 47 - 48 /** - 49 * @returns a sequential integer starting at 0 - 50 */ - 51 jasmine.Env.prototype.nextSuiteId = function () { - 52 return this.nextSuiteId_++; - 53 }; - 54 - 55 /** - 56 * Register a reporter to receive status updates from Jasmine. - 57 * @param {jasmine.Reporter} reporter An object which will receive status updates. - 58 */ - 59 jasmine.Env.prototype.addReporter = function(reporter) { - 60 this.reporter.addReporter(reporter); - 61 }; - 62 - 63 jasmine.Env.prototype.execute = function() { - 64 this.currentRunner_.execute(); - 65 }; - 66 - 67 jasmine.Env.prototype.describe = function(description, specDefinitions) { - 68 var suite = new jasmine.Suite(this, description, specDefinitions, this.currentSuite); - 69 - 70 var parentSuite = this.currentSuite; - 71 if (parentSuite) { - 72 parentSuite.add(suite); - 73 } else { - 74 this.currentRunner_.add(suite); - 75 } - 76 - 77 this.currentSuite = suite; - 78 - 79 specDefinitions.call(suite); + 44 jasmine.Env.prototype.version = function () { + 45 if (jasmine.version_) { + 46 return jasmine.version_; + 47 } else { + 48 throw new Error('Version not set'); + 49 } + 50 }; + 51 + 52 /** + 53 * @returns a sequential integer starting at 0 + 54 */ + 55 jasmine.Env.prototype.nextSpecId = function () { + 56 return this.nextSpecId_++; + 57 }; + 58 + 59 /** + 60 * @returns a sequential integer starting at 0 + 61 */ + 62 jasmine.Env.prototype.nextSuiteId = function () { + 63 return this.nextSuiteId_++; + 64 }; + 65 + 66 /** + 67 * Register a reporter to receive status updates from Jasmine. + 68 * @param {jasmine.Reporter} reporter An object which will receive status updates. + 69 */ + 70 jasmine.Env.prototype.addReporter = function(reporter) { + 71 this.reporter.addReporter(reporter); + 72 }; + 73 + 74 jasmine.Env.prototype.execute = function() { + 75 this.currentRunner_.execute(); + 76 }; + 77 + 78 jasmine.Env.prototype.describe = function(description, specDefinitions) { + 79 var suite = new jasmine.Suite(this, description, specDefinitions, this.currentSuite); 80 - 81 this.currentSuite = parentSuite; - 82 - 83 return suite; - 84 }; - 85 - 86 jasmine.Env.prototype.beforeEach = function(beforeEachFunction) { - 87 if (this.currentSuite) { - 88 this.currentSuite.beforeEach(beforeEachFunction); - 89 } else { - 90 this.currentRunner_.beforeEach(beforeEachFunction); - 91 } - 92 }; + 81 var parentSuite = this.currentSuite; + 82 if (parentSuite) { + 83 parentSuite.add(suite); + 84 } else { + 85 this.currentRunner_.add(suite); + 86 } + 87 + 88 this.currentSuite = suite; + 89 + 90 specDefinitions.call(suite); + 91 + 92 this.currentSuite = parentSuite; 93 - 94 jasmine.Env.prototype.currentRunner = function () { - 95 return this.currentRunner_; - 96 }; - 97 - 98 jasmine.Env.prototype.afterEach = function(afterEachFunction) { - 99 if (this.currentSuite) { -100 this.currentSuite.afterEach(afterEachFunction); -101 } else { -102 this.currentRunner_.afterEach(afterEachFunction); -103 } + 94 return suite; + 95 }; + 96 + 97 jasmine.Env.prototype.beforeEach = function(beforeEachFunction) { + 98 if (this.currentSuite) { + 99 this.currentSuite.beforeEach(beforeEachFunction); +100 } else { +101 this.currentRunner_.beforeEach(beforeEachFunction); +102 } +103 }; 104 -105 }; -106 -107 jasmine.Env.prototype.xdescribe = function(desc, specDefinitions) { -108 return { -109 execute: function() { -110 } -111 }; -112 }; -113 -114 jasmine.Env.prototype.it = function(description, func) { -115 var spec = new jasmine.Spec(this, this.currentSuite, description); -116 this.currentSuite.add(spec); -117 this.currentSpec = spec; -118 -119 if (func) { -120 spec.runs(func); -121 } -122 -123 return spec; -124 }; -125 -126 jasmine.Env.prototype.xit = function(desc, func) { -127 return { -128 id: this.nextSpecId(), -129 runs: function() { -130 } -131 }; -132 }; +105 jasmine.Env.prototype.currentRunner = function () { +106 return this.currentRunner_; +107 }; +108 +109 jasmine.Env.prototype.afterEach = function(afterEachFunction) { +110 if (this.currentSuite) { +111 this.currentSuite.afterEach(afterEachFunction); +112 } else { +113 this.currentRunner_.afterEach(afterEachFunction); +114 } +115 +116 }; +117 +118 jasmine.Env.prototype.xdescribe = function(desc, specDefinitions) { +119 return { +120 execute: function() { +121 } +122 }; +123 }; +124 +125 jasmine.Env.prototype.it = function(description, func) { +126 var spec = new jasmine.Spec(this, this.currentSuite, description); +127 this.currentSuite.add(spec); +128 this.currentSpec = spec; +129 +130 if (func) { +131 spec.runs(func); +132 } 133 -134 jasmine.Env.prototype.compareObjects_ = function(a, b, mismatchKeys, mismatchValues) { -135 if (a.__Jasmine_been_here_before__ === b && b.__Jasmine_been_here_before__ === a) { -136 return true; -137 } -138 -139 a.__Jasmine_been_here_before__ = b; -140 b.__Jasmine_been_here_before__ = a; -141 -142 var hasKey = function(obj, keyName) { -143 return obj != null && obj[keyName] !== undefined; -144 }; -145 -146 for (var property in b) { -147 if (!hasKey(a, property) && hasKey(b, property)) { -148 mismatchKeys.push("expected has key '" + property + "', but missing from actual."); -149 } -150 } -151 for (property in a) { -152 if (!hasKey(b, property) && hasKey(a, property)) { -153 mismatchKeys.push("expected missing key '" + property + "', but present in actual."); -154 } -155 } -156 for (property in b) { -157 if (property == '__Jasmine_been_here_before__') continue; -158 if (!this.equals_(a[property], b[property], mismatchKeys, mismatchValues)) { -159 mismatchValues.push("'" + property + "' was '" + (b[property] ? jasmine.util.htmlEscape(b[property].toString()) : b[property]) + "' in expected, but was '" + (a[property] ? jasmine.util.htmlEscape(a[property].toString()) : a[property]) + "' in actual."); +134 return spec; +135 }; +136 +137 jasmine.Env.prototype.xit = function(desc, func) { +138 return { +139 id: this.nextSpecId(), +140 runs: function() { +141 } +142 }; +143 }; +144 +145 jasmine.Env.prototype.compareObjects_ = function(a, b, mismatchKeys, mismatchValues) { +146 if (a.__Jasmine_been_here_before__ === b && b.__Jasmine_been_here_before__ === a) { +147 return true; +148 } +149 +150 a.__Jasmine_been_here_before__ = b; +151 b.__Jasmine_been_here_before__ = a; +152 +153 var hasKey = function(obj, keyName) { +154 return obj != null && obj[keyName] !== jasmine.undefined; +155 }; +156 +157 for (var property in b) { +158 if (!hasKey(a, property) && hasKey(b, property)) { +159 mismatchKeys.push("expected has key '" + property + "', but missing from actual."); 160 } 161 } -162 -163 if (jasmine.isArray_(a) && jasmine.isArray_(b) && a.length != b.length) { -164 mismatchValues.push("arrays were not the same length"); -165 } -166 -167 delete a.__Jasmine_been_here_before__; -168 delete b.__Jasmine_been_here_before__; -169 return (mismatchKeys.length == 0 && mismatchValues.length == 0); -170 }; -171 -172 jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) { -173 mismatchKeys = mismatchKeys || []; -174 mismatchValues = mismatchValues || []; -175 -176 if (a === b) return true; +162 for (property in a) { +163 if (!hasKey(b, property) && hasKey(a, property)) { +164 mismatchKeys.push("expected missing key '" + property + "', but present in actual."); +165 } +166 } +167 for (property in b) { +168 if (property == '__Jasmine_been_here_before__') continue; +169 if (!this.equals_(a[property], b[property], mismatchKeys, mismatchValues)) { +170 mismatchValues.push("'" + property + "' was '" + (b[property] ? jasmine.util.htmlEscape(b[property].toString()) : b[property]) + "' in expected, but was '" + (a[property] ? jasmine.util.htmlEscape(a[property].toString()) : a[property]) + "' in actual."); +171 } +172 } +173 +174 if (jasmine.isArray_(a) && jasmine.isArray_(b) && a.length != b.length) { +175 mismatchValues.push("arrays were not the same length"); +176 } 177 -178 if (a === undefined || a === null || b === undefined || b === null) { -179 return (a == undefined && b == undefined); -180 } -181 -182 if (jasmine.isDomNode(a) && jasmine.isDomNode(b)) { -183 return a === b; -184 } -185 -186 if (a instanceof Date && b instanceof Date) { -187 return a.getTime() == b.getTime(); -188 } -189 -190 if (a instanceof jasmine.Matchers.Any) { -191 return a.matches(b); -192 } -193 -194 if (b instanceof jasmine.Matchers.Any) { -195 return b.matches(a); -196 } -197 -198 if (typeof a === "object" && typeof b === "object") { -199 return this.compareObjects_(a, b, mismatchKeys, mismatchValues); -200 } -201 -202 for (var i = 0; i < this.equalityTesters_.length; i++) { -203 var equalityTester = this.equalityTesters_[i]; -204 var result = equalityTester(a, b, this, mismatchKeys, mismatchValues); -205 if (result !== undefined) return result; -206 } -207 -208 //Straight check -209 return (a === b); -210 }; -211 -212 jasmine.Env.prototype.contains_ = function(haystack, needle) { -213 if (jasmine.isArray_(haystack)) { -214 for (var i = 0; i < haystack.length; i++) { -215 if (this.equals_(haystack[i], needle)) return true; -216 } -217 return false; -218 } -219 return haystack.indexOf(needle) >= 0; -220 }; -221 -222 jasmine.Env.prototype.addEqualityTester = function(equalityTester) { -223 this.equalityTesters_.push(equalityTester); -224 }; -225 \ No newline at end of file +178 delete a.__Jasmine_been_here_before__; +179 delete b.__Jasmine_been_here_before__; +180 return (mismatchKeys.length == 0 && mismatchValues.length == 0); +181 }; +182 +183 jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) { +184 mismatchKeys = mismatchKeys || []; +185 mismatchValues = mismatchValues || []; +186 +187 if (a === b) return true; +188 +189 if (a === jasmine.undefined || a === null || b === jasmine.undefined || b === null) { +190 return (a == jasmine.undefined && b == jasmine.undefined); +191 } +192 +193 if (jasmine.isDomNode(a) && jasmine.isDomNode(b)) { +194 return a === b; +195 } +196 +197 if (a instanceof Date && b instanceof Date) { +198 return a.getTime() == b.getTime(); +199 } +200 +201 if (a instanceof jasmine.Matchers.Any) { +202 return a.matches(b); +203 } +204 +205 if (b instanceof jasmine.Matchers.Any) { +206 return b.matches(a); +207 } +208 +209 if (typeof a === "object" && typeof b === "object") { +210 return this.compareObjects_(a, b, mismatchKeys, mismatchValues); +211 } +212 +213 for (var i = 0; i < this.equalityTesters_.length; i++) { +214 var equalityTester = this.equalityTesters_[i]; +215 var result = equalityTester(a, b, this, mismatchKeys, mismatchValues); +216 if (result !== jasmine.undefined) return result; +217 } +218 +219 //Straight check +220 return (a === b); +221 }; +222 +223 jasmine.Env.prototype.contains_ = function(haystack, needle) { +224 if (jasmine.isArray_(haystack)) { +225 for (var i = 0; i < haystack.length; i++) { +226 if (this.equals_(haystack[i], needle)) return true; +227 } +228 return false; +229 } +230 return haystack.indexOf(needle) >= 0; +231 }; +232 +233 jasmine.Env.prototype.addEqualityTester = function(equalityTester) { +234 this.equalityTesters_.push(equalityTester); +235 }; +236 \ No newline at end of file diff --git a/doc/symbols/src/src_JsApiReporter.js.html b/doc/symbols/src/src_JsApiReporter.js.html index fa4bd53..8097661 100644 --- a/doc/symbols/src/src_JsApiReporter.js.html +++ b/doc/symbols/src/src_JsApiReporter.js.html @@ -86,25 +86,26 @@ 79 80 jasmine.JsApiReporter.prototype.summarizeResult_ = function(result){ 81 var summaryMessages = []; - 82 for (var messageIndex in result.messages) { - 83 var resultMessage = result.messages[messageIndex]; - 84 summaryMessages.push({ - 85 text: resultMessage.text, - 86 passed: resultMessage.passed ? resultMessage.passed() : true, - 87 type: resultMessage.type, - 88 message: resultMessage.message, - 89 trace: { - 90 stack: resultMessage.passed && !resultMessage.passed() ? resultMessage.trace.stack : undefined - 91 } - 92 }); - 93 }; - 94 - 95 var summaryResult = { - 96 result : result.result, - 97 messages : summaryMessages - 98 }; - 99 -100 return summaryResult; -101 }; -102 -103 \ No newline at end of file + 82 var messagesLength = result.messages.length + 83 for (var messageIndex = 0; messageIndex < messagesLength; messageIndex++) { + 84 var resultMessage = result.messages[messageIndex]; + 85 summaryMessages.push({ + 86 text: resultMessage.text, + 87 passed: resultMessage.passed ? resultMessage.passed() : true, + 88 type: resultMessage.type, + 89 message: resultMessage.message, + 90 trace: { + 91 stack: resultMessage.passed && !resultMessage.passed() ? resultMessage.trace.stack : jasmine.undefined + 92 } + 93 }); + 94 }; + 95 + 96 var summaryResult = { + 97 result : result.result, + 98 messages : summaryMessages + 99 }; +100 +101 return summaryResult; +102 }; +103 +104 \ No newline at end of file diff --git a/doc/symbols/src/src_Matchers.js.html b/doc/symbols/src/src_Matchers.js.html index 17275cf..0000319 100644 --- a/doc/symbols/src/src_Matchers.js.html +++ b/doc/symbols/src/src_Matchers.js.html @@ -31,57 +31,57 @@ 24 return result; 25 }; 26 - 27 jasmine.Matchers.matcherFn_ = function(matcherName, options) { - 28 return function () { - 29 jasmine.util.extend(this, options); - 30 var matcherArgs = jasmine.util.argsToArray(arguments); - 31 var args = [this.actual].concat(matcherArgs); - 32 var result = options.test.apply(this, args); - 33 var message; - 34 if (!result) { - 35 message = options.message.apply(this, args); - 36 } - 37 var expectationResult = new jasmine.ExpectationResult({ - 38 matcherName: matcherName, - 39 passed: result, - 40 expected: matcherArgs.length > 1 ? matcherArgs : matcherArgs[0], - 41 actual: this.actual, - 42 message: message - 43 }); - 44 this.spec.addMatcherResult(expectationResult); - 45 return result; - 46 }; - 47 }; - 48 - 49 - 50 - 51 - 52 /** - 53 * toBe: compares the actual to the expected using === - 54 * @param expected - 55 */ - 56 - 57 jasmine.Matchers.prototype.toBe = jasmine.Matchers.matcherFn_('toBe', { - 58 test: function (actual, expected) { - 59 return actual === expected; - 60 }, - 61 message: function(actual, expected) { - 62 return "Expected " + jasmine.pp(actual) + " to be " + jasmine.pp(expected); - 63 } - 64 }); - 65 - 66 /** - 67 * toNotBe: compares the actual to the expected using !== - 68 * @param expected - 69 */ - 70 jasmine.Matchers.prototype.toNotBe = jasmine.Matchers.matcherFn_('toNotBe', { - 71 test: function (actual, expected) { - 72 return actual !== expected; - 73 }, - 74 message: function(actual, expected) { - 75 return "Expected " + jasmine.pp(actual) + " to not be " + jasmine.pp(expected); - 76 } - 77 }); + 27 jasmine.Matchers.matcherFn_ = function(matcherName, matcherFunction) { + 28 return function() { + 29 var matcherArgs = jasmine.util.argsToArray(arguments); + 30 var result = matcherFunction.apply(this, arguments); + 31 var message; + 32 if (!result) { + 33 if (this.message) { + 34 message = this.message.apply(this, arguments); + 35 } else { + 36 var englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) { return ' ' + s.toLowerCase(); }); + 37 message = "Expected " + jasmine.pp(this.actual) + " " + englishyPredicate; + 38 if (matcherArgs.length > 0) { + 39 for (var i = 0; i < matcherArgs.length; i++) { + 40 if (i > 0) message += ","; + 41 message += " " + jasmine.pp(matcherArgs[i]); + 42 } + 43 } + 44 message += "."; + 45 } + 46 } + 47 var expectationResult = new jasmine.ExpectationResult({ + 48 matcherName: matcherName, + 49 passed: result, + 50 expected: matcherArgs.length > 1 ? matcherArgs : matcherArgs[0], + 51 actual: this.actual, + 52 message: message + 53 }); + 54 this.spec.addMatcherResult(expectationResult); + 55 return result; + 56 }; + 57 }; + 58 + 59 + 60 + 61 + 62 /** + 63 * toBe: compares the actual to the expected using === + 64 * @param expected + 65 */ + 66 + 67 jasmine.Matchers.prototype.toBe = function(expected) { + 68 return this.actual === expected; + 69 }; + 70 + 71 /** + 72 * toNotBe: compares the actual to the expected using !== + 73 * @param expected + 74 */ + 75 jasmine.Matchers.prototype.toNotBe = function(expected) { + 76 return this.actual !== expected; + 77 }; 78 79 /** 80 * toEqual: compares the actual to the expected using common sense equality. Handles Objects, Arrays, etc. @@ -89,311 +89,233 @@ 82 * @param expected 83 */ 84 - 85 jasmine.Matchers.prototype.toEqual = jasmine.Matchers.matcherFn_('toEqual', { - 86 test: function (actual, expected) { - 87 return this.env.equals_(actual, expected); - 88 }, - 89 message: function(actual, expected) { - 90 return "Expected " + jasmine.pp(actual) + " to equal " + jasmine.pp(expected); - 91 } - 92 }); - 93 - 94 /** - 95 * toNotEqual: compares the actual to the expected using the ! of jasmine.Matchers.toEqual - 96 * @param expected - 97 */ - 98 jasmine.Matchers.prototype.toNotEqual = jasmine.Matchers.matcherFn_('toNotEqual', { - 99 test: function (actual, expected) { -100 return !this.env.equals_(actual, expected); -101 }, -102 message: function(actual, expected) { -103 return "Expected " + jasmine.pp(actual) + " to not equal " + jasmine.pp(expected); -104 } -105 }); + 85 jasmine.Matchers.prototype.toEqual = function(expected) { + 86 return this.env.equals_(this.actual, expected); + 87 }; + 88 + 89 /** + 90 * toNotEqual: compares the actual to the expected using the ! of jasmine.Matchers.toEqual + 91 * @param expected + 92 */ + 93 jasmine.Matchers.prototype.toNotEqual = function(expected) { + 94 return !this.env.equals_(this.actual, expected); + 95 }; + 96 + 97 /** + 98 * Matcher that compares the actual to the expected using a regular expression. Constructs a RegExp, so takes + 99 * a pattern or a String. +100 * +101 * @param reg_exp +102 */ +103 jasmine.Matchers.prototype.toMatch = function(expected) { +104 return new RegExp(expected).test(this.actual); +105 }; 106 107 /** -108 * Matcher that compares the actual to the expected using a regular expression. Constructs a RegExp, so takes -109 * a pattern or a String. -110 * -111 * @param reg_exp -112 */ -113 jasmine.Matchers.prototype.toMatch = jasmine.Matchers.matcherFn_('toMatch', { -114 test: function(actual, expected) { -115 return new RegExp(expected).test(actual); -116 }, -117 message: function(actual, expected) { -118 return jasmine.pp(actual) + " does not match the regular expression " + new RegExp(expected).toString(); -119 } -120 }); +108 * Matcher that compares the actual to the expected using the boolean inverse of jasmine.Matchers.toMatch +109 * @param reg_exp +110 */ +111 jasmine.Matchers.prototype.toNotMatch = function(expected) { +112 return !(new RegExp(expected).test(this.actual)); +113 }; +114 +115 /** +116 * Matcher that compares the actual to jasmine.undefined. +117 */ +118 jasmine.Matchers.prototype.toBeDefined = function() { +119 return (this.actual !== jasmine.undefined); +120 }; 121 122 /** -123 * Matcher that compares the actual to the expected using the boolean inverse of jasmine.Matchers.toMatch -124 * @param reg_exp -125 */ -126 -127 jasmine.Matchers.prototype.toNotMatch = jasmine.Matchers.matcherFn_('toNotMatch', { -128 test: function(actual, expected) { -129 return !(new RegExp(expected).test(actual)); -130 }, -131 message: function(actual, expected) { -132 return jasmine.pp(actual) + " should not match " + new RegExp(expected).toString(); -133 } -134 }); +123 * Matcher that compares the actual to jasmine.undefined. +124 */ +125 jasmine.Matchers.prototype.toBeUndefined = function() { +126 return (this.actual === jasmine.undefined); +127 }; +128 +129 /** +130 * Matcher that compares the actual to null. +131 */ +132 jasmine.Matchers.prototype.toBeNull = function() { +133 return (this.actual === null); +134 }; 135 136 /** -137 * Matcher that compares the acutal to undefined. +137 * Matcher that boolean not-nots the actual. 138 */ -139 -140 jasmine.Matchers.prototype.toBeDefined = jasmine.Matchers.matcherFn_('toBeDefined', { -141 test: function(actual) { -142 return (actual !== undefined); -143 }, -144 message: function() { -145 return 'Expected actual to not be undefined.'; -146 } -147 }); -148 -149 /** -150 * Matcher that compares the acutal to undefined. -151 */ -152 -153 jasmine.Matchers.prototype.toBeUndefined = jasmine.Matchers.matcherFn_('toBeUndefined', { -154 test: function(actual) { -155 return (actual === undefined); -156 }, -157 message: function(actual) { -158 return 'Expected ' + jasmine.pp(actual) + ' to be undefined.'; -159 } -160 }); -161 -162 /** -163 * Matcher that compares the actual to null. -164 * -165 */ -166 jasmine.Matchers.prototype.toBeNull = jasmine.Matchers.matcherFn_('toBeNull', { -167 test: function(actual) { -168 return (actual === null); -169 }, -170 message: function(actual) { -171 return 'Expected ' + jasmine.pp(actual) + ' to be null.'; -172 } -173 }); -174 -175 /** -176 * Matcher that boolean not-nots the actual. -177 */ -178 jasmine.Matchers.prototype.toBeTruthy = jasmine.Matchers.matcherFn_('toBeTruthy', { -179 test: function(actual) { -180 return !!actual; -181 }, -182 message: function() { -183 return 'Expected actual to be truthy'; -184 } -185 }); -186 -187 -188 /** -189 * Matcher that boolean nots the actual. -190 */ -191 jasmine.Matchers.prototype.toBeFalsy = jasmine.Matchers.matcherFn_('toBeFalsy', { -192 test: function(actual) { -193 return !actual; -194 }, -195 message: function(actual) { -196 return 'Expected ' + jasmine.pp(actual) + ' to be falsy'; -197 } -198 }); +139 jasmine.Matchers.prototype.toBeTruthy = function() { +140 return !!this.actual; +141 }; +142 +143 +144 /** +145 * Matcher that boolean nots the actual. +146 */ +147 jasmine.Matchers.prototype.toBeFalsy = function() { +148 return !this.actual; +149 }; +150 +151 /** +152 * Matcher that checks to see if the actual, a Jasmine spy, was called. +153 */ +154 jasmine.Matchers.prototype.wasCalled = function() { +155 if (arguments.length > 0) { +156 throw new Error('wasCalled does not take arguments, use wasCalledWith'); +157 } +158 +159 if (!jasmine.isSpy(this.actual)) { +160 throw new Error('Expected a spy, but got ' + jasmine.Matchers.pp(this.actual) + '.'); +161 } +162 +163 this.message = function() { +164 return "Expected spy " + this.actual.identity + " to have been called."; +165 }; +166 +167 return this.actual.wasCalled; +168 }; +169 +170 /** +171 * Matcher that checks to see if the actual, a Jasmine spy, was not called. +172 */ +173 jasmine.Matchers.prototype.wasNotCalled = function() { +174 if (arguments.length > 0) { +175 throw new Error('wasNotCalled does not take arguments'); +176 } +177 +178 if (!jasmine.isSpy(this.actual)) { +179 throw new Error('Expected a spy, but got ' + jasmine.Matchers.pp(this.actual) + '.'); +180 } +181 +182 this.message = function() { +183 return "Expected spy " + this.actual.identity + " to not have been called."; +184 }; +185 +186 return !this.actual.wasCalled; +187 }; +188 +189 /** +190 * Matcher that checks to see if the actual, a Jasmine spy, was called with a set of parameters. +191 * +192 * @example +193 * +194 */ +195 jasmine.Matchers.prototype.wasCalledWith = function() { +196 if (!jasmine.isSpy(this.actual)) { +197 throw new Error('Expected a spy, but got ' + jasmine.Matchers.pp(this.actual) + '.'); +198 } 199 -200 /** -201 * Matcher that checks to see if the acutal, a Jasmine spy, was called. -202 */ -203 -204 jasmine.Matchers.prototype.wasCalled = jasmine.Matchers.matcherFn_('wasCalled', { -205 getActual_: function() { -206 var args = jasmine.util.argsToArray(arguments); -207 if (args.length > 1) { -208 throw(new Error('wasCalled does not take arguments, use wasCalledWith')); -209 } -210 return args.splice(0, 1)[0]; -211 }, -212 test: function() { -213 var actual = this.getActual_.apply(this, arguments); -214 if (!actual || !actual.isSpy) { -215 return false; -216 } -217 return actual.wasCalled; -218 }, -219 message: function() { -220 var actual = this.getActual_.apply(this, arguments); -221 if (!actual || !actual.isSpy) { -222 return 'Actual is not a spy.'; -223 } -224 return "Expected spy " + actual.identity + " to have been called."; -225 } -226 }); -227 -228 /** -229 * Matcher that checks to see if the acutal, a Jasmine spy, was not called. -230 */ -231 jasmine.Matchers.prototype.wasNotCalled = jasmine.Matchers.matcherFn_('wasNotCalled', { -232 getActual_: function() { -233 var args = jasmine.util.argsToArray(arguments); -234 return args.splice(0, 1)[0]; -235 }, -236 test: function() { -237 var actual = this.getActual_.apply(this, arguments); -238 if (!actual || !actual.isSpy) { -239 return false; -240 } -241 return !actual.wasCalled; -242 }, -243 message: function() { -244 var actual = this.getActual_.apply(this, arguments); -245 if (!actual || !actual.isSpy) { -246 return 'Actual is not a spy.'; -247 } -248 return "Expected spy " + actual.identity + " to not have been called."; -249 } -250 }); -251 -252 jasmine.Matchers.prototype.wasCalledWith = jasmine.Matchers.matcherFn_('wasCalledWith', { -253 test: function() { -254 var args = jasmine.util.argsToArray(arguments); -255 var actual = args.splice(0, 1)[0]; -256 if (!actual || !actual.isSpy) { -257 return false; -258 } -259 return this.env.contains_(actual.argsForCall, args); -260 }, -261 message: function() { -262 var args = jasmine.util.argsToArray(arguments); -263 var actual = args.splice(0, 1)[0]; -264 var message; -265 if (!actual || !actual.isSpy) { -266 message = 'Actual is not a spy'; -267 } else { -268 message = "Expected spy to have been called with " + jasmine.pp(args) + " but was called with " + actual.argsForCall; -269 } -270 return message; -271 } -272 }); +200 this.message = function() { +201 if (this.actual.callCount == 0) { +202 return "Expected spy to have been called with " + jasmine.pp(arguments) + " but it was never called."; +203 } else { +204 return "Expected spy to have been called with " + jasmine.pp(arguments) + " but was called with " + jasmine.pp(this.actual.argsForCall); +205 } +206 }; +207 +208 return this.env.contains_(this.actual.argsForCall, jasmine.util.argsToArray(arguments)); +209 }; +210 +211 jasmine.Matchers.prototype.wasNotCalledWith = function() { +212 if (!jasmine.isSpy(this.actual)) { +213 throw new Error('Expected a spy, but got ' + jasmine.Matchers.pp(this.actual) + '.'); +214 } +215 +216 this.message = function() { +217 return "Expected spy not to have been called with " + jasmine.pp(arguments) + " but it was"; +218 }; +219 +220 return !this.env.contains_(this.actual.argsForCall, jasmine.util.argsToArray(arguments)); +221 }; +222 +223 /** +224 * Matcher that checks that the expected item is an element in the actual Array. +225 * +226 * @param {Object} item +227 */ +228 jasmine.Matchers.prototype.toContain = function(expected) { +229 return this.env.contains_(this.actual, expected); +230 }; +231 +232 /** +233 * Matcher that checks that the expected item is NOT an element in the actual Array. +234 * +235 * @param {Object} item +236 */ +237 jasmine.Matchers.prototype.toNotContain = function(expected) { +238 return !this.env.contains_(this.actual, expected); +239 }; +240 +241 jasmine.Matchers.prototype.toBeLessThan = function(expected) { +242 return this.actual < expected; +243 }; +244 +245 jasmine.Matchers.prototype.toBeGreaterThan = function(expected) { +246 return this.actual > expected; +247 }; +248 +249 /** +250 * Matcher that checks that the expected exception was thrown by the actual. +251 * +252 * @param {String} expectedException +253 */ +254 jasmine.Matchers.prototype.toThrow = function(expected) { +255 function getException_(actual, expected) { +256 var exception; +257 if (typeof actual != 'function') { +258 throw new Error('Actual is not a function'); +259 } +260 try { +261 actual(); +262 } catch (e) { +263 exception = e; +264 } +265 return exception; +266 } +267 +268 var result = false; +269 var exception = getException_(this.actual, expected); +270 if (exception) { +271 result = (expected === jasmine.undefined || this.env.equals_(exception.message || exception, expected.message || expected)); +272 } 273 -274 /** -275 * Matcher that checks to see if the acutal, a Jasmine spy, was called with a set of parameters. -276 * -277 * @example -278 * -279 */ -280 -281 /** -282 * Matcher that checks that the expected item is an element in the actual Array. -283 * -284 * @param {Object} item -285 */ -286 -287 jasmine.Matchers.prototype.toContain = jasmine.Matchers.matcherFn_('toContain', { -288 test: function(actual, expected) { -289 return this.env.contains_(actual, expected); -290 }, -291 message: function(actual, expected) { -292 return 'Expected ' + jasmine.pp(actual) + ' to contain ' + jasmine.pp(expected); +274 this.message = function(expected) { +275 var exception = getException_(this.actual, expected); +276 if (exception && (expected === jasmine.undefined || !this.env.equals_(exception.message || exception, expected.message || expected))) { +277 return ["Expected function to throw", expected.message || expected, ", but it threw", exception.message || exception ].join(' '); +278 } else { +279 return "Expected function to throw an exception."; +280 } +281 }; +282 +283 return result; +284 }; +285 +286 jasmine.Matchers.Any = function(expectedClass) { +287 this.expectedClass = expectedClass; +288 }; +289 +290 jasmine.Matchers.Any.prototype.matches = function(other) { +291 if (this.expectedClass == String) { +292 return typeof other == 'string' || other instanceof String; 293 } -294 }); -295 -296 /** -297 * Matcher that checks that the expected item is NOT an element in the actual Array. -298 * -299 * @param {Object} item -300 */ -301 jasmine.Matchers.prototype.toNotContain = jasmine.Matchers.matcherFn_('toNotContain', { -302 test: function(actual, expected) { -303 return !this.env.contains_(actual, expected); -304 }, -305 message: function(actual, expected) { -306 return 'Expected ' + jasmine.pp(actual) + ' to not contain ' + jasmine.pp(expected); -307 } -308 }); +294 +295 if (this.expectedClass == Number) { +296 return typeof other == 'number' || other instanceof Number; +297 } +298 +299 if (this.expectedClass == Function) { +300 return typeof other == 'function' || other instanceof Function; +301 } +302 +303 if (this.expectedClass == Object) { +304 return typeof other == 'object'; +305 } +306 +307 return other instanceof this.expectedClass; +308 }; 309 -310 jasmine.Matchers.prototype.toBeLessThan = jasmine.Matchers.matcherFn_('toBeLessThan', { -311 test: function(actual, expected) { -312 return actual < expected; -313 }, -314 message: function(actual, expected) { -315 return 'Expected ' + jasmine.pp(actual) + ' to be less than ' + jasmine.pp(expected); -316 } -317 }); -318 -319 jasmine.Matchers.prototype.toBeGreaterThan = jasmine.Matchers.matcherFn_('toBeGreaterThan', { -320 test: function(actual, expected) { -321 return actual > expected; -322 }, -323 message: function(actual, expected) { -324 return 'Expected ' + jasmine.pp(actual) + ' to be greater than ' + jasmine.pp(expected); -325 } -326 }); -327 -328 /** -329 * Matcher that checks that the expected exception was thrown by the actual. -330 * -331 * @param {String} expectedException -332 */ -333 jasmine.Matchers.prototype.toThrow = jasmine.Matchers.matcherFn_('toThrow', { -334 getException_: function(actual, expected) { -335 var exception; -336 if (typeof actual != 'function') { -337 throw new Error('Actual is not a function'); -338 } -339 try { -340 actual(); -341 } catch (e) { -342 exception = e; -343 } -344 return exception; -345 }, -346 test: function(actual, expected) { -347 var result = false; -348 var exception = this.getException_(actual, expected); -349 if (exception) { -350 result = (expected === undefined || this.env.equals_(exception.message || exception, expected.message || expected)); -351 } -352 return result; -353 }, -354 message: function(actual, expected) { -355 var exception = this.getException_(actual, expected); -356 if (exception && (expected === undefined || !this.env.equals_(exception.message || exception, expected.message || expected))) { -357 return ["Expected function to throw", expected.message || expected, ", but it threw", exception.message || exception ].join(' '); -358 } else { -359 return "Expected function to throw an exception."; -360 } -361 } -362 }); -363 -364 jasmine.Matchers.Any = function(expectedClass) { -365 this.expectedClass = expectedClass; -366 }; -367 -368 jasmine.Matchers.Any.prototype.matches = function(other) { -369 if (this.expectedClass == String) { -370 return typeof other == 'string' || other instanceof String; -371 } -372 -373 if (this.expectedClass == Number) { -374 return typeof other == 'number' || other instanceof Number; -375 } -376 -377 if (this.expectedClass == Function) { -378 return typeof other == 'function' || other instanceof Function; -379 } -380 -381 if (this.expectedClass == Object) { -382 return typeof other == 'object'; -383 } -384 -385 return other instanceof this.expectedClass; -386 }; -387 -388 jasmine.Matchers.Any.prototype.toString = function() { -389 return '<jasmine.any(' + this.expectedClass + ')>'; -390 }; -391 -392 \ No newline at end of file +310 jasmine.Matchers.Any.prototype.toString = function() { +311 return '<jasmine.any(' + this.expectedClass + ')>'; +312 }; +313 +314 \ No newline at end of file diff --git a/doc/symbols/src/src_PrettyPrinter.js.html b/doc/symbols/src/src_PrettyPrinter.js.html index 0508164..6b112d0 100644 --- a/doc/symbols/src/src_PrettyPrinter.js.html +++ b/doc/symbols/src/src_PrettyPrinter.js.html @@ -16,113 +16,115 @@ 9 * Formats a value in a nice, human-readable string. 10 * 11 * @param value - 12 * @returns {String} - 13 */ - 14 jasmine.PrettyPrinter.prototype.format = function(value) { - 15 if (this.ppNestLevel_ > 40) { - 16 // return '(jasmine.pp nested too deeply!)'; - 17 throw new Error('jasmine.PrettyPrinter: format() nested too deeply!'); - 18 } - 19 - 20 this.ppNestLevel_++; - 21 try { - 22 if (value === undefined) { - 23 this.emitScalar('undefined'); - 24 } else if (value === null) { - 25 this.emitScalar('null'); - 26 } else if (value.navigator && value.frames && value.setTimeout) { - 27 this.emitScalar('<window>'); - 28 } else if (value instanceof jasmine.Matchers.Any) { - 29 this.emitScalar(value.toString()); - 30 } else if (typeof value === 'string') { - 31 this.emitString(value); - 32 } else if (typeof value === 'function') { - 33 this.emitScalar('Function'); - 34 } else if (typeof value.nodeType === 'number') { - 35 this.emitScalar('HTMLNode'); - 36 } else if (value instanceof Date) { - 37 this.emitScalar('Date(' + value + ')'); - 38 } else if (value.__Jasmine_been_here_before__) { - 39 this.emitScalar('<circular reference: ' + (jasmine.isArray_(value) ? 'Array' : 'Object') + '>'); - 40 } else if (jasmine.isArray_(value) || typeof value == 'object') { - 41 value.__Jasmine_been_here_before__ = true; - 42 if (jasmine.isArray_(value)) { - 43 this.emitArray(value); - 44 } else { - 45 this.emitObject(value); - 46 } - 47 delete value.__Jasmine_been_here_before__; - 48 } else { - 49 this.emitScalar(value.toString()); - 50 } - 51 } finally { - 52 this.ppNestLevel_--; - 53 } - 54 }; - 55 - 56 jasmine.PrettyPrinter.prototype.iterateObject = function(obj, fn) { - 57 for (var property in obj) { - 58 if (property == '__Jasmine_been_here_before__') continue; - 59 fn(property, obj.__lookupGetter__ ? (obj.__lookupGetter__(property) != null) : false); - 60 } - 61 }; - 62 - 63 jasmine.PrettyPrinter.prototype.emitArray = jasmine.unimplementedMethod_; - 64 jasmine.PrettyPrinter.prototype.emitObject = jasmine.unimplementedMethod_; - 65 jasmine.PrettyPrinter.prototype.emitScalar = jasmine.unimplementedMethod_; - 66 jasmine.PrettyPrinter.prototype.emitString = jasmine.unimplementedMethod_; - 67 - 68 jasmine.StringPrettyPrinter = function() { - 69 jasmine.PrettyPrinter.call(this); - 70 - 71 this.string = ''; - 72 }; - 73 jasmine.util.inherit(jasmine.StringPrettyPrinter, jasmine.PrettyPrinter); - 74 - 75 jasmine.StringPrettyPrinter.prototype.emitScalar = function(value) { - 76 this.append(value); - 77 }; - 78 - 79 jasmine.StringPrettyPrinter.prototype.emitString = function(value) { - 80 this.append("'" + value + "'"); - 81 }; - 82 - 83 jasmine.StringPrettyPrinter.prototype.emitArray = function(array) { - 84 this.append('[ '); - 85 for (var i = 0; i < array.length; i++) { - 86 if (i > 0) { - 87 this.append(', '); - 88 } - 89 this.format(array[i]); - 90 } - 91 this.append(' ]'); - 92 }; - 93 - 94 jasmine.StringPrettyPrinter.prototype.emitObject = function(obj) { - 95 var self = this; - 96 this.append('{ '); - 97 var first = true; - 98 - 99 this.iterateObject(obj, function(property, isGetter) { -100 if (first) { -101 first = false; -102 } else { -103 self.append(', '); -104 } -105 -106 self.append(property); -107 self.append(' : '); -108 if (isGetter) { -109 self.append('<getter>'); -110 } else { -111 self.format(obj[property]); -112 } -113 }); -114 -115 this.append(' }'); -116 }; -117 -118 jasmine.StringPrettyPrinter.prototype.append = function(value) { -119 this.string += value; -120 }; -121 \ No newline at end of file + 12 */ + 13 jasmine.PrettyPrinter.prototype.format = function(value) { + 14 if (this.ppNestLevel_ > 40) { + 15 throw new Error('jasmine.PrettyPrinter: format() nested too deeply!'); + 16 } + 17 + 18 this.ppNestLevel_++; + 19 try { + 20 if (value === jasmine.undefined) { + 21 this.emitScalar('undefined'); + 22 } else if (value === null) { + 23 this.emitScalar('null'); + 24 } else if (value.navigator && value.frames && value.setTimeout) { + 25 this.emitScalar('<window>'); + 26 } else if (value instanceof jasmine.Matchers.Any) { + 27 this.emitScalar(value.toString()); + 28 } else if (typeof value === 'string') { + 29 this.emitString(value); + 30 } else if (jasmine.isSpy(value)) { + 31 this.emitScalar("spy on " + value.identity); + 32 } else if (value instanceof RegExp) { + 33 this.emitScalar(value.toString()); + 34 } else if (typeof value === 'function') { + 35 this.emitScalar('Function'); + 36 } else if (typeof value.nodeType === 'number') { + 37 this.emitScalar('HTMLNode'); + 38 } else if (value instanceof Date) { + 39 this.emitScalar('Date(' + value + ')'); + 40 } else if (value.__Jasmine_been_here_before__) { + 41 this.emitScalar('<circular reference: ' + (jasmine.isArray_(value) ? 'Array' : 'Object') + '>'); + 42 } else if (jasmine.isArray_(value) || typeof value == 'object') { + 43 value.__Jasmine_been_here_before__ = true; + 44 if (jasmine.isArray_(value)) { + 45 this.emitArray(value); + 46 } else { + 47 this.emitObject(value); + 48 } + 49 delete value.__Jasmine_been_here_before__; + 50 } else { + 51 this.emitScalar(value.toString()); + 52 } + 53 } finally { + 54 this.ppNestLevel_--; + 55 } + 56 }; + 57 + 58 jasmine.PrettyPrinter.prototype.iterateObject = function(obj, fn) { + 59 for (var property in obj) { + 60 if (property == '__Jasmine_been_here_before__') continue; + 61 fn(property, obj.__lookupGetter__ ? (obj.__lookupGetter__(property) != null) : false); + 62 } + 63 }; + 64 + 65 jasmine.PrettyPrinter.prototype.emitArray = jasmine.unimplementedMethod_; + 66 jasmine.PrettyPrinter.prototype.emitObject = jasmine.unimplementedMethod_; + 67 jasmine.PrettyPrinter.prototype.emitScalar = jasmine.unimplementedMethod_; + 68 jasmine.PrettyPrinter.prototype.emitString = jasmine.unimplementedMethod_; + 69 + 70 jasmine.StringPrettyPrinter = function() { + 71 jasmine.PrettyPrinter.call(this); + 72 + 73 this.string = ''; + 74 }; + 75 jasmine.util.inherit(jasmine.StringPrettyPrinter, jasmine.PrettyPrinter); + 76 + 77 jasmine.StringPrettyPrinter.prototype.emitScalar = function(value) { + 78 this.append(value); + 79 }; + 80 + 81 jasmine.StringPrettyPrinter.prototype.emitString = function(value) { + 82 this.append("'" + value + "'"); + 83 }; + 84 + 85 jasmine.StringPrettyPrinter.prototype.emitArray = function(array) { + 86 this.append('[ '); + 87 for (var i = 0; i < array.length; i++) { + 88 if (i > 0) { + 89 this.append(', '); + 90 } + 91 this.format(array[i]); + 92 } + 93 this.append(' ]'); + 94 }; + 95 + 96 jasmine.StringPrettyPrinter.prototype.emitObject = function(obj) { + 97 var self = this; + 98 this.append('{ '); + 99 var first = true; +100 +101 this.iterateObject(obj, function(property, isGetter) { +102 if (first) { +103 first = false; +104 } else { +105 self.append(', '); +106 } +107 +108 self.append(property); +109 self.append(' : '); +110 if (isGetter) { +111 self.append('<getter>'); +112 } else { +113 self.format(obj[property]); +114 } +115 }); +116 +117 this.append(' }'); +118 }; +119 +120 jasmine.StringPrettyPrinter.prototype.append = function(value) { +121 this.string += value; +122 }; +123 \ No newline at end of file diff --git a/doc/symbols/src/src_Spec.js.html b/doc/symbols/src/src_Spec.js.html index b550cf3..2523022 100644 --- a/doc/symbols/src/src_Spec.js.html +++ b/doc/symbols/src/src_Spec.js.html @@ -17,199 +17,197 @@ 10 if (!env) { 11 throw new Error('jasmine.Env() required'); 12 } - 13 ; - 14 if (!suite) { - 15 throw new Error('jasmine.Suite() required'); - 16 } - 17 ; - 18 var spec = this; - 19 spec.id = env.nextSpecId ? env.nextSpecId() : null; - 20 spec.env = env; - 21 spec.suite = suite; - 22 spec.description = description; - 23 spec.queue = new jasmine.Queue(env); - 24 - 25 spec.afterCallbacks = []; - 26 spec.spies_ = []; - 27 - 28 spec.results_ = new jasmine.NestedResults(); - 29 spec.results_.description = description; - 30 spec.matchersClass = null; - 31 }; - 32 - 33 jasmine.Spec.prototype.getFullName = function() { - 34 return this.suite.getFullName() + ' ' + this.description + '.'; - 35 }; - 36 - 37 - 38 jasmine.Spec.prototype.results = function() { - 39 return this.results_; - 40 }; - 41 - 42 jasmine.Spec.prototype.log = function(message) { - 43 return this.results_.log(message); - 44 }; - 45 - 46 /** @deprecated */ - 47 jasmine.Spec.prototype.getResults = function() { - 48 return this.results_; - 49 }; - 50 - 51 jasmine.Spec.prototype.runs = function (func) { - 52 var block = new jasmine.Block(this.env, func, this); - 53 this.addToQueue(block); - 54 return this; - 55 }; - 56 - 57 jasmine.Spec.prototype.addToQueue = function (block) { - 58 if (this.queue.isRunning()) { - 59 this.queue.insertNext(block); - 60 } else { - 61 this.queue.add(block); - 62 } - 63 }; - 64 - 65 jasmine.Spec.prototype.addMatcherResult = function(result) { - 66 this.results_.addResult(result); - 67 }; - 68 - 69 jasmine.Spec.prototype.expect = function(actual) { - 70 return new (this.getMatchersClass_())(this.env, actual, this); - 71 }; - 72 - 73 jasmine.Spec.prototype.waits = function(timeout) { - 74 var waitsFunc = new jasmine.WaitsBlock(this.env, timeout, this); - 75 this.addToQueue(waitsFunc); - 76 return this; - 77 }; - 78 - 79 jasmine.Spec.prototype.waitsFor = function(timeout, latchFunction, timeoutMessage) { - 80 var waitsForFunc = new jasmine.WaitsForBlock(this.env, timeout, latchFunction, timeoutMessage, this); - 81 this.addToQueue(waitsForFunc); - 82 return this; - 83 }; - 84 - 85 jasmine.Spec.prototype.fail = function (e) { - 86 var expectationResult = new jasmine.ExpectationResult({ - 87 passed: false, - 88 message: e ? jasmine.util.formatException(e) : 'Exception' - 89 }); - 90 this.results_.addResult(expectationResult); - 91 }; - 92 - 93 jasmine.Spec.prototype.getMatchersClass_ = function() { - 94 return this.matchersClass || jasmine.Matchers; - 95 }; - 96 - 97 jasmine.Spec.prototype.addMatchers = function(matchersPrototype) { - 98 var parent = this.getMatchersClass_(); - 99 var newMatchersClass = function() { -100 parent.apply(this, arguments); -101 }; -102 jasmine.util.inherit(newMatchersClass, parent); -103 for (var method in matchersPrototype) { -104 newMatchersClass.prototype[method] = matchersPrototype[method]; -105 } -106 this.matchersClass = newMatchersClass; -107 }; -108 -109 jasmine.Spec.prototype.finishCallback = function() { -110 this.env.reporter.reportSpecResults(this); -111 }; -112 -113 jasmine.Spec.prototype.finish = function(onComplete) { -114 this.removeAllSpies(); -115 this.finishCallback(); -116 if (onComplete) { -117 onComplete(); -118 } -119 }; + 13 if (!suite) { + 14 throw new Error('jasmine.Suite() required'); + 15 } + 16 var spec = this; + 17 spec.id = env.nextSpecId ? env.nextSpecId() : null; + 18 spec.env = env; + 19 spec.suite = suite; + 20 spec.description = description; + 21 spec.queue = new jasmine.Queue(env); + 22 + 23 spec.afterCallbacks = []; + 24 spec.spies_ = []; + 25 + 26 spec.results_ = new jasmine.NestedResults(); + 27 spec.results_.description = description; + 28 spec.matchersClass = null; + 29 }; + 30 + 31 jasmine.Spec.prototype.getFullName = function() { + 32 return this.suite.getFullName() + ' ' + this.description + '.'; + 33 }; + 34 + 35 + 36 jasmine.Spec.prototype.results = function() { + 37 return this.results_; + 38 }; + 39 + 40 jasmine.Spec.prototype.log = function(message) { + 41 return this.results_.log(message); + 42 }; + 43 + 44 /** @deprecated */ + 45 jasmine.Spec.prototype.getResults = function() { + 46 return this.results_; + 47 }; + 48 + 49 jasmine.Spec.prototype.runs = function (func) { + 50 var block = new jasmine.Block(this.env, func, this); + 51 this.addToQueue(block); + 52 return this; + 53 }; + 54 + 55 jasmine.Spec.prototype.addToQueue = function (block) { + 56 if (this.queue.isRunning()) { + 57 this.queue.insertNext(block); + 58 } else { + 59 this.queue.add(block); + 60 } + 61 }; + 62 + 63 jasmine.Spec.prototype.addMatcherResult = function(result) { + 64 this.results_.addResult(result); + 65 }; + 66 + 67 jasmine.Spec.prototype.expect = function(actual) { + 68 return new (this.getMatchersClass_())(this.env, actual, this); + 69 }; + 70 + 71 jasmine.Spec.prototype.waits = function(timeout) { + 72 var waitsFunc = new jasmine.WaitsBlock(this.env, timeout, this); + 73 this.addToQueue(waitsFunc); + 74 return this; + 75 }; + 76 + 77 jasmine.Spec.prototype.waitsFor = function(timeout, latchFunction, timeoutMessage) { + 78 var waitsForFunc = new jasmine.WaitsForBlock(this.env, timeout, latchFunction, timeoutMessage, this); + 79 this.addToQueue(waitsForFunc); + 80 return this; + 81 }; + 82 + 83 jasmine.Spec.prototype.fail = function (e) { + 84 var expectationResult = new jasmine.ExpectationResult({ + 85 passed: false, + 86 message: e ? jasmine.util.formatException(e) : 'Exception' + 87 }); + 88 this.results_.addResult(expectationResult); + 89 }; + 90 + 91 jasmine.Spec.prototype.getMatchersClass_ = function() { + 92 return this.matchersClass || this.env.matchersClass; + 93 }; + 94 + 95 jasmine.Spec.prototype.addMatchers = function(matchersPrototype) { + 96 var parent = this.getMatchersClass_(); + 97 var newMatchersClass = function() { + 98 parent.apply(this, arguments); + 99 }; +100 jasmine.util.inherit(newMatchersClass, parent); +101 for (var method in matchersPrototype) { +102 newMatchersClass.prototype[method] = matchersPrototype[method]; +103 } +104 this.matchersClass = newMatchersClass; +105 }; +106 +107 jasmine.Spec.prototype.finishCallback = function() { +108 this.env.reporter.reportSpecResults(this); +109 }; +110 +111 jasmine.Spec.prototype.finish = function(onComplete) { +112 this.removeAllSpies(); +113 this.finishCallback(); +114 if (onComplete) { +115 onComplete(); +116 } +117 }; +118 +119 jasmine.Spec.prototype.after = function(doAfter, test) { 120 -121 jasmine.Spec.prototype.after = function(doAfter, test) { -122 -123 if (this.queue.isRunning()) { -124 this.queue.add(new jasmine.Block(this.env, doAfter, this)); -125 } else { -126 this.afterCallbacks.unshift(doAfter); -127 } -128 }; -129 -130 jasmine.Spec.prototype.execute = function(onComplete) { -131 var spec = this; -132 if (!spec.env.specFilter(spec)) { -133 spec.results_.skipped = true; -134 spec.finish(onComplete); -135 return; -136 } -137 this.env.reporter.log('>> Jasmine Running ' + this.suite.description + ' ' + this.description + '...'); +121 if (this.queue.isRunning()) { +122 this.queue.add(new jasmine.Block(this.env, doAfter, this)); +123 } else { +124 this.afterCallbacks.unshift(doAfter); +125 } +126 }; +127 +128 jasmine.Spec.prototype.execute = function(onComplete) { +129 var spec = this; +130 if (!spec.env.specFilter(spec)) { +131 spec.results_.skipped = true; +132 spec.finish(onComplete); +133 return; +134 } +135 this.env.reporter.log('>> Jasmine Running ' + this.suite.description + ' ' + this.description + '...'); +136 +137 spec.env.currentSpec = spec; 138 -139 spec.env.currentSpec = spec; +139 spec.addBeforesAndAftersToQueue(); 140 -141 spec.addBeforesAndAftersToQueue(); -142 -143 spec.queue.start(function () { -144 spec.finish(onComplete); -145 }); -146 }; -147 -148 jasmine.Spec.prototype.addBeforesAndAftersToQueue = function() { -149 var runner = this.env.currentRunner(); -150 for (var suite = this.suite; suite; suite = suite.parentSuite) { -151 for (var i = 0; i < suite.before_.length; i++) { -152 this.queue.addBefore(new jasmine.Block(this.env, suite.before_[i], this)); -153 } -154 } -155 for (var i = 0; i < runner.before_.length; i++) { -156 this.queue.addBefore(new jasmine.Block(this.env, runner.before_[i], this)); -157 } -158 for (i = 0; i < this.afterCallbacks.length; i++) { -159 this.queue.add(new jasmine.Block(this.env, this.afterCallbacks[i], this)); -160 } -161 for (suite = this.suite; suite; suite = suite.parentSuite) { -162 for (var i = 0; i < suite.after_.length; i++) { -163 this.queue.add(new jasmine.Block(this.env, suite.after_[i], this)); -164 } -165 } -166 for (var i = 0; i < runner.after_.length; i++) { -167 this.queue.add(new jasmine.Block(this.env, runner.after_[i], this)); -168 } -169 }; -170 -171 jasmine.Spec.prototype.explodes = function() { -172 throw 'explodes function should not have been called'; -173 }; -174 -175 jasmine.Spec.prototype.spyOn = function(obj, methodName, ignoreMethodDoesntExist) { -176 if (obj == undefined) { -177 throw "spyOn could not find an object to spy upon for " + methodName + "()"; -178 } -179 -180 if (!ignoreMethodDoesntExist && obj[methodName] === undefined) { -181 throw methodName + '() method does not exist'; -182 } -183 -184 if (!ignoreMethodDoesntExist && obj[methodName] && obj[methodName].isSpy) { -185 throw new Error(methodName + ' has already been spied upon'); -186 } +141 spec.queue.start(function () { +142 spec.finish(onComplete); +143 }); +144 }; +145 +146 jasmine.Spec.prototype.addBeforesAndAftersToQueue = function() { +147 var runner = this.env.currentRunner(); +148 for (var suite = this.suite; suite; suite = suite.parentSuite) { +149 for (var i = 0; i < suite.before_.length; i++) { +150 this.queue.addBefore(new jasmine.Block(this.env, suite.before_[i], this)); +151 } +152 } +153 for (var i = 0; i < runner.before_.length; i++) { +154 this.queue.addBefore(new jasmine.Block(this.env, runner.before_[i], this)); +155 } +156 for (i = 0; i < this.afterCallbacks.length; i++) { +157 this.queue.add(new jasmine.Block(this.env, this.afterCallbacks[i], this)); +158 } +159 for (suite = this.suite; suite; suite = suite.parentSuite) { +160 for (var i = 0; i < suite.after_.length; i++) { +161 this.queue.add(new jasmine.Block(this.env, suite.after_[i], this)); +162 } +163 } +164 for (var i = 0; i < runner.after_.length; i++) { +165 this.queue.add(new jasmine.Block(this.env, runner.after_[i], this)); +166 } +167 }; +168 +169 jasmine.Spec.prototype.explodes = function() { +170 throw 'explodes function should not have been called'; +171 }; +172 +173 jasmine.Spec.prototype.spyOn = function(obj, methodName, ignoreMethodDoesntExist) { +174 if (obj == jasmine.undefined) { +175 throw "spyOn could not find an object to spy upon for " + methodName + "()"; +176 } +177 +178 if (!ignoreMethodDoesntExist && obj[methodName] === jasmine.undefined) { +179 throw methodName + '() method does not exist'; +180 } +181 +182 if (!ignoreMethodDoesntExist && obj[methodName] && obj[methodName].isSpy) { +183 throw new Error(methodName + ' has already been spied upon'); +184 } +185 +186 var spyObj = jasmine.createSpy(methodName); 187 -188 var spyObj = jasmine.createSpy(methodName); -189 -190 this.spies_.push(spyObj); -191 spyObj.baseObj = obj; -192 spyObj.methodName = methodName; -193 spyObj.originalValue = obj[methodName]; +188 this.spies_.push(spyObj); +189 spyObj.baseObj = obj; +190 spyObj.methodName = methodName; +191 spyObj.originalValue = obj[methodName]; +192 +193 obj[methodName] = spyObj; 194 -195 obj[methodName] = spyObj; -196 -197 return spyObj; -198 }; -199 -200 jasmine.Spec.prototype.removeAllSpies = function() { -201 for (var i = 0; i < this.spies_.length; i++) { -202 var spy = this.spies_[i]; -203 spy.baseObj[spy.methodName] = spy.originalValue; -204 } -205 this.spies_ = []; -206 }; -207 -208 \ No newline at end of file +195 return spyObj; +196 }; +197 +198 jasmine.Spec.prototype.removeAllSpies = function() { +199 for (var i = 0; i < this.spies_.length; i++) { +200 var spy = this.spies_[i]; +201 spy.baseObj[spy.methodName] = spy.originalValue; +202 } +203 this.spies_ = []; +204 }; +205 +206 \ No newline at end of file diff --git a/doc/symbols/src/src_base.js.html b/doc/symbols/src/src_base.js.html index 1b48e2c..388f185 100644 --- a/doc/symbols/src/src_base.js.html +++ b/doc/symbols/src/src_base.js.html @@ -20,520 +20,536 @@ 13 }; 14 15 /** - 16 * Default interval for event loop yields. Small values here may result in slow test running. Zero means no updates until all tests have completed. - 17 * - 18 */ - 19 jasmine.DEFAULT_UPDATE_INTERVAL = 250; - 20 - 21 /** - 22 * Allows for bound functions to be comapred. Internal use only. - 23 * - 24 * @ignore - 25 * @private - 26 * @param base {Object} bound 'this' for the function - 27 * @param name {Function} function to find - 28 */ - 29 jasmine.bindOriginal_ = function(base, name) { - 30 var original = base[name]; - 31 if (original.apply) { - 32 return function() { - 33 return original.apply(base, arguments); - 34 }; - 35 } else { - 36 // IE support - 37 return window[name]; - 38 } - 39 }; - 40 - 41 jasmine.setTimeout = jasmine.bindOriginal_(window, 'setTimeout'); - 42 jasmine.clearTimeout = jasmine.bindOriginal_(window, 'clearTimeout'); - 43 jasmine.setInterval = jasmine.bindOriginal_(window, 'setInterval'); - 44 jasmine.clearInterval = jasmine.bindOriginal_(window, 'clearInterval'); - 45 - 46 jasmine.MessageResult = function(text) { - 47 this.type = 'MessageResult'; - 48 this.text = text; - 49 this.trace = new Error(); // todo: test better - 50 }; - 51 - 52 jasmine.ExpectationResult = function(params) { - 53 this.type = 'ExpectationResult'; - 54 this.matcherName = params.matcherName; - 55 this.passed_ = params.passed; - 56 this.expected = params.expected; - 57 this.actual = params.actual; - 58 - 59 /** @deprecated */ - 60 this.details = params.details; - 61 - 62 this.message = this.passed_ ? 'Passed.' : params.message; - 63 this.trace = this.passed_ ? '' : new Error(this.message); - 64 }; - 65 - 66 jasmine.ExpectationResult.prototype.passed = function () { - 67 return this.passed_; - 68 }; - 69 - 70 /** - 71 * Getter for the Jasmine environment. Ensures one gets created - 72 */ - 73 jasmine.getEnv = function() { - 74 return jasmine.currentEnv_ = jasmine.currentEnv_ || new jasmine.Env(); - 75 }; - 76 - 77 /** - 78 * @ignore - 79 * @private - 80 * @param value - 81 * @returns {Boolean} - 82 */ - 83 jasmine.isArray_ = function(value) { - 84 return value && - 85 typeof value === 'object' && - 86 typeof value.length === 'number' && - 87 typeof value.splice === 'function' && - 88 !(value.propertyIsEnumerable('length')); - 89 }; - 90 - 91 /** - 92 * Pretty printer for expecations. Takes any object and turns it into a human-readable string. - 93 * - 94 * @param value {Object} an object to be outputted - 95 * @returns {String} - 96 */ - 97 jasmine.pp = function(value) { - 98 var stringPrettyPrinter = new jasmine.StringPrettyPrinter(); - 99 stringPrettyPrinter.format(value); -100 return stringPrettyPrinter.string; -101 }; -102 -103 /** -104 * Returns true if the object is a DOM Node. -105 * -106 * @param {Object} obj object to check -107 * @returns {Boolean} -108 */ -109 jasmine.isDomNode = function(obj) { -110 return obj['nodeType'] > 0; -111 }; -112 -113 /** -114 * Returns a matchable 'generic' object of the class type. For use in expecations of type when values don't matter. -115 * -116 * @example -117 * // don't care about which function is passed in, as long as it's a function -118 * expect(mySpy).wasCalledWith(jasmine.any(Function)); -119 * -120 * @param {Class} clazz -121 * @returns matchable object of the type clazz -122 */ -123 jasmine.any = function(clazz) { -124 return new jasmine.Matchers.Any(clazz); -125 }; -126 -127 /** -128 * Jasmine Spies are test doubles that can act as stubs, spies, fakes or when used in an expecation, mocks. -129 * -130 * Spies should be created in test setup, before expectations. They can then be checked, using the standard Jasmine -131 * expectation syntax. Spies can be checked if they were called or not and what the calling params were. -132 * -133 * A Spy has the following mehtod: wasCalled, callCount, mostRecentCall, and argsForCall (see docs) -134 * Spies are torn down at the end of every spec. -135 * -136 * Note: Do <b>not</b> call new jasmine.Spy() directly - a spy must be created using spyOn, jasmine.createSpy or jasmine.createSpyObj. + 16 * Use <code>jasmine.undefined</code> instead of <code>undefined</code>, since <code>undefined</code is just + 17 * a plain old variable and may be redefined by somebody else. + 18 * + 19 * @private + 20 */ + 21 jasmine.undefined = jasmine.___undefined___; + 22 + 23 /** + 24 * Default interval for event loop yields. Small values here may result in slow test running. Zero means no updates until all tests have completed. + 25 * + 26 */ + 27 jasmine.DEFAULT_UPDATE_INTERVAL = 250; + 28 + 29 /** + 30 * Allows for bound functions to be compared. Internal use only. + 31 * + 32 * @ignore + 33 * @private + 34 * @param base {Object} bound 'this' for the function + 35 * @param name {Function} function to find + 36 */ + 37 jasmine.bindOriginal_ = function(base, name) { + 38 var original = base[name]; + 39 if (original.apply) { + 40 return function() { + 41 return original.apply(base, arguments); + 42 }; + 43 } else { + 44 // IE support + 45 return window[name]; + 46 } + 47 }; + 48 + 49 jasmine.setTimeout = jasmine.bindOriginal_(window, 'setTimeout'); + 50 jasmine.clearTimeout = jasmine.bindOriginal_(window, 'clearTimeout'); + 51 jasmine.setInterval = jasmine.bindOriginal_(window, 'setInterval'); + 52 jasmine.clearInterval = jasmine.bindOriginal_(window, 'clearInterval'); + 53 + 54 jasmine.MessageResult = function(text) { + 55 this.type = 'MessageResult'; + 56 this.text = text; + 57 this.trace = new Error(); // todo: test better + 58 }; + 59 + 60 jasmine.ExpectationResult = function(params) { + 61 this.type = 'ExpectationResult'; + 62 this.matcherName = params.matcherName; + 63 this.passed_ = params.passed; + 64 this.expected = params.expected; + 65 this.actual = params.actual; + 66 + 67 /** @deprecated */ + 68 this.details = params.details; + 69 + 70 this.message = this.passed_ ? 'Passed.' : params.message; + 71 this.trace = this.passed_ ? '' : new Error(this.message); + 72 }; + 73 + 74 jasmine.ExpectationResult.prototype.passed = function () { + 75 return this.passed_; + 76 }; + 77 + 78 /** + 79 * Getter for the Jasmine environment. Ensures one gets created + 80 */ + 81 jasmine.getEnv = function() { + 82 return jasmine.currentEnv_ = jasmine.currentEnv_ || new jasmine.Env(); + 83 }; + 84 + 85 /** + 86 * @ignore + 87 * @private + 88 * @param value + 89 * @returns {Boolean} + 90 */ + 91 jasmine.isArray_ = function(value) { + 92 return value && + 93 typeof value === 'object' && + 94 typeof value.length === 'number' && + 95 typeof value.splice === 'function' && + 96 !(value.propertyIsEnumerable('length')); + 97 }; + 98 + 99 /** +100 * Pretty printer for expecations. Takes any object and turns it into a human-readable string. +101 * +102 * @param value {Object} an object to be outputted +103 * @returns {String} +104 */ +105 jasmine.pp = function(value) { +106 var stringPrettyPrinter = new jasmine.StringPrettyPrinter(); +107 stringPrettyPrinter.format(value); +108 return stringPrettyPrinter.string; +109 }; +110 +111 /** +112 * Returns true if the object is a DOM Node. +113 * +114 * @param {Object} obj object to check +115 * @returns {Boolean} +116 */ +117 jasmine.isDomNode = function(obj) { +118 return obj['nodeType'] > 0; +119 }; +120 +121 /** +122 * Returns a matchable 'generic' object of the class type. For use in expecations of type when values don't matter. +123 * +124 * @example +125 * // don't care about which function is passed in, as long as it's a function +126 * expect(mySpy).wasCalledWith(jasmine.any(Function)); +127 * +128 * @param {Class} clazz +129 * @returns matchable object of the type clazz +130 */ +131 jasmine.any = function(clazz) { +132 return new jasmine.Matchers.Any(clazz); +133 }; +134 +135 /** +136 * Jasmine Spies are test doubles that can act as stubs, spies, fakes or when used in an expecation, mocks. 137 * -138 * @example -139 * // a stub -140 * var myStub = jasmine.createSpy('myStub'); // can be used anywhere -141 * -142 * // spy example -143 * var foo = { -144 * not: function(bool) { return !bool; } -145 * } -146 * -147 * // actual foo.not will not be called, execution stops -148 * spyOn(foo, 'not'); -149 -150 // foo.not spied upon, execution will continue to implementation -151 * spyOn(foo, 'not').andCallThrough(); -152 * -153 * // fake example -154 * var foo = { -155 * not: function(bool) { return !bool; } -156 * } -157 * -158 * // foo.not(val) will return val -159 * spyOn(foo, 'not').andCallFake(function(value) {return value;}); +138 * Spies should be created in test setup, before expectations. They can then be checked, using the standard Jasmine +139 * expectation syntax. Spies can be checked if they were called or not and what the calling params were. +140 * +141 * A Spy has the following mehtod: wasCalled, callCount, mostRecentCall, and argsForCall (see docs) +142 * Spies are torn down at the end of every spec. +143 * +144 * Note: Do <b>not</b> call new jasmine.Spy() directly - a spy must be created using spyOn, jasmine.createSpy or jasmine.createSpyObj. +145 * +146 * @example +147 * // a stub +148 * var myStub = jasmine.createSpy('myStub'); // can be used anywhere +149 * +150 * // spy example +151 * var foo = { +152 * not: function(bool) { return !bool; } +153 * } +154 * +155 * // actual foo.not will not be called, execution stops +156 * spyOn(foo, 'not'); +157 +158 // foo.not spied upon, execution will continue to implementation +159 * spyOn(foo, 'not').andCallThrough(); 160 * -161 * // mock example -162 * foo.not(7 == 7); -163 * expect(foo.not).wasCalled(); -164 * expect(foo.not).wasCalledWith(true); +161 * // fake example +162 * var foo = { +163 * not: function(bool) { return !bool; } +164 * } 165 * -166 * @constructor -167 * @see spyOn, jasmine.createSpy, jasmine.createSpyObj -168 * @param {String} name -169 */ -170 jasmine.Spy = function(name) { -171 /** -172 * The name of the spy, if provided. -173 */ -174 this.identity = name || 'unknown'; -175 /** -176 * Is this Object a spy? -177 */ -178 this.isSpy = true; +166 * // foo.not(val) will return val +167 * spyOn(foo, 'not').andCallFake(function(value) {return value;}); +168 * +169 * // mock example +170 * foo.not(7 == 7); +171 * expect(foo.not).wasCalled(); +172 * expect(foo.not).wasCalledWith(true); +173 * +174 * @constructor +175 * @see spyOn, jasmine.createSpy, jasmine.createSpyObj +176 * @param {String} name +177 */ +178 jasmine.Spy = function(name) { 179 /** -180 * The actual function this spy stubs. +180 * The name of the spy, if provided. 181 */ -182 this.plan = function() { -183 }; -184 /** -185 * Tracking of the most recent call to the spy. -186 * @example -187 * var mySpy = jasmine.createSpy('foo'); -188 * mySpy(1, 2); -189 * mySpy.mostRecentCall.args = [1, 2]; -190 */ -191 this.mostRecentCall = {}; -192 -193 /** -194 * Holds arguments for each call to the spy, indexed by call count -195 * @example -196 * var mySpy = jasmine.createSpy('foo'); -197 * mySpy(1, 2); -198 * mySpy(7, 8); -199 * mySpy.mostRecentCall.args = [7, 8]; -200 * mySpy.argsForCall[0] = [1, 2]; -201 * mySpy.argsForCall[1] = [7, 8]; -202 */ -203 this.argsForCall = []; -204 this.calls = []; -205 }; -206 -207 /** -208 * Tells a spy to call through to the actual implemenatation. -209 * -210 * @example -211 * var foo = { -212 * bar: function() { // do some stuff } -213 * } -214 * -215 * // defining a spy on an existing property: foo.bar -216 * spyOn(foo, 'bar').andCallThrough(); -217 */ -218 jasmine.Spy.prototype.andCallThrough = function() { -219 this.plan = this.originalValue; -220 return this; -221 }; -222 -223 /** -224 * For setting the return value of a spy. -225 * -226 * @example -227 * // defining a spy from scratch: foo() returns 'baz' -228 * var foo = jasmine.createSpy('spy on foo').andReturn('baz'); -229 * -230 * // defining a spy on an existing property: foo.bar() returns 'baz' -231 * spyOn(foo, 'bar').andReturn('baz'); -232 * -233 * @param {Object} value -234 */ -235 jasmine.Spy.prototype.andReturn = function(value) { -236 this.plan = function() { -237 return value; -238 }; -239 return this; -240 }; -241 -242 /** -243 * For throwing an exception when a spy is called. -244 * -245 * @example -246 * // defining a spy from scratch: foo() throws an exception w/ message 'ouch' -247 * var foo = jasmine.createSpy('spy on foo').andThrow('baz'); -248 * -249 * // defining a spy on an existing property: foo.bar() throws an exception w/ message 'ouch' -250 * spyOn(foo, 'bar').andThrow('baz'); -251 * -252 * @param {String} exceptionMsg -253 */ -254 jasmine.Spy.prototype.andThrow = function(exceptionMsg) { -255 this.plan = function() { -256 throw exceptionMsg; -257 }; -258 return this; -259 }; -260 -261 /** -262 * Calls an alternate implementation when a spy is called. -263 * -264 * @example -265 * var baz = function() { -266 * // do some stuff, return something -267 * } -268 * // defining a spy from scratch: foo() calls the function baz -269 * var foo = jasmine.createSpy('spy on foo').andCall(baz); -270 * -271 * // defining a spy on an existing property: foo.bar() calls an anonymnous function -272 * spyOn(foo, 'bar').andCall(function() { return 'baz';} ); -273 * -274 * @param {Function} fakeFunc -275 */ -276 jasmine.Spy.prototype.andCallFake = function(fakeFunc) { -277 this.plan = fakeFunc; -278 return this; -279 }; -280 -281 /** -282 * Resets all of a spy's the tracking variables so that it can be used again. -283 * -284 * @example -285 * spyOn(foo, 'bar'); -286 * -287 * foo.bar(); -288 * -289 * expect(foo.bar.callCount).toEqual(1); -290 * -291 * foo.bar.reset(); -292 * -293 * expect(foo.bar.callCount).toEqual(0); -294 */ -295 jasmine.Spy.prototype.reset = function() { -296 this.wasCalled = false; -297 this.callCount = 0; -298 this.argsForCall = []; -299 this.calls = []; -300 this.mostRecentCall = {}; -301 }; -302 -303 jasmine.createSpy = function(name) { -304 -305 var spyObj = function() { -306 spyObj.wasCalled = true; -307 spyObj.callCount++; -308 var args = jasmine.util.argsToArray(arguments); -309 spyObj.mostRecentCall.object = this; -310 spyObj.mostRecentCall.args = args; -311 spyObj.argsForCall.push(args); -312 spyObj.calls.push({object: this, args: args}); -313 return spyObj.plan.apply(this, arguments); -314 }; -315 -316 var spy = new jasmine.Spy(name); -317 -318 for (var prop in spy) { -319 spyObj[prop] = spy[prop]; -320 } -321 -322 spyObj.reset(); +182 this.identity = name || 'unknown'; +183 /** +184 * Is this Object a spy? +185 */ +186 this.isSpy = true; +187 /** +188 * The actual function this spy stubs. +189 */ +190 this.plan = function() { +191 }; +192 /** +193 * Tracking of the most recent call to the spy. +194 * @example +195 * var mySpy = jasmine.createSpy('foo'); +196 * mySpy(1, 2); +197 * mySpy.mostRecentCall.args = [1, 2]; +198 */ +199 this.mostRecentCall = {}; +200 +201 /** +202 * Holds arguments for each call to the spy, indexed by call count +203 * @example +204 * var mySpy = jasmine.createSpy('foo'); +205 * mySpy(1, 2); +206 * mySpy(7, 8); +207 * mySpy.mostRecentCall.args = [7, 8]; +208 * mySpy.argsForCall[0] = [1, 2]; +209 * mySpy.argsForCall[1] = [7, 8]; +210 */ +211 this.argsForCall = []; +212 this.calls = []; +213 }; +214 +215 /** +216 * Tells a spy to call through to the actual implemenatation. +217 * +218 * @example +219 * var foo = { +220 * bar: function() { // do some stuff } +221 * } +222 * +223 * // defining a spy on an existing property: foo.bar +224 * spyOn(foo, 'bar').andCallThrough(); +225 */ +226 jasmine.Spy.prototype.andCallThrough = function() { +227 this.plan = this.originalValue; +228 return this; +229 }; +230 +231 /** +232 * For setting the return value of a spy. +233 * +234 * @example +235 * // defining a spy from scratch: foo() returns 'baz' +236 * var foo = jasmine.createSpy('spy on foo').andReturn('baz'); +237 * +238 * // defining a spy on an existing property: foo.bar() returns 'baz' +239 * spyOn(foo, 'bar').andReturn('baz'); +240 * +241 * @param {Object} value +242 */ +243 jasmine.Spy.prototype.andReturn = function(value) { +244 this.plan = function() { +245 return value; +246 }; +247 return this; +248 }; +249 +250 /** +251 * For throwing an exception when a spy is called. +252 * +253 * @example +254 * // defining a spy from scratch: foo() throws an exception w/ message 'ouch' +255 * var foo = jasmine.createSpy('spy on foo').andThrow('baz'); +256 * +257 * // defining a spy on an existing property: foo.bar() throws an exception w/ message 'ouch' +258 * spyOn(foo, 'bar').andThrow('baz'); +259 * +260 * @param {String} exceptionMsg +261 */ +262 jasmine.Spy.prototype.andThrow = function(exceptionMsg) { +263 this.plan = function() { +264 throw exceptionMsg; +265 }; +266 return this; +267 }; +268 +269 /** +270 * Calls an alternate implementation when a spy is called. +271 * +272 * @example +273 * var baz = function() { +274 * // do some stuff, return something +275 * } +276 * // defining a spy from scratch: foo() calls the function baz +277 * var foo = jasmine.createSpy('spy on foo').andCall(baz); +278 * +279 * // defining a spy on an existing property: foo.bar() calls an anonymnous function +280 * spyOn(foo, 'bar').andCall(function() { return 'baz';} ); +281 * +282 * @param {Function} fakeFunc +283 */ +284 jasmine.Spy.prototype.andCallFake = function(fakeFunc) { +285 this.plan = fakeFunc; +286 return this; +287 }; +288 +289 /** +290 * Resets all of a spy's the tracking variables so that it can be used again. +291 * +292 * @example +293 * spyOn(foo, 'bar'); +294 * +295 * foo.bar(); +296 * +297 * expect(foo.bar.callCount).toEqual(1); +298 * +299 * foo.bar.reset(); +300 * +301 * expect(foo.bar.callCount).toEqual(0); +302 */ +303 jasmine.Spy.prototype.reset = function() { +304 this.wasCalled = false; +305 this.callCount = 0; +306 this.argsForCall = []; +307 this.calls = []; +308 this.mostRecentCall = {}; +309 }; +310 +311 jasmine.createSpy = function(name) { +312 +313 var spyObj = function() { +314 spyObj.wasCalled = true; +315 spyObj.callCount++; +316 var args = jasmine.util.argsToArray(arguments); +317 spyObj.mostRecentCall.object = this; +318 spyObj.mostRecentCall.args = args; +319 spyObj.argsForCall.push(args); +320 spyObj.calls.push({object: this, args: args}); +321 return spyObj.plan.apply(this, arguments); +322 }; 323 -324 return spyObj; -325 }; -326 -327 /** -328 * Creates a more complicated spy: an Object that has every property a function that is a spy. Used for stubbing something -329 * large in one call. -330 * -331 * @param {String} baseName name of spy class -332 * @param {Array} methodNames array of names of methods to make spies -333 */ -334 jasmine.createSpyObj = function(baseName, methodNames) { -335 var obj = {}; -336 for (var i = 0; i < methodNames.length; i++) { -337 obj[methodNames[i]] = jasmine.createSpy(baseName + '.' + methodNames[i]); -338 } -339 return obj; -340 }; -341 -342 jasmine.log = function(message) { -343 jasmine.getEnv().currentSpec.log(message); -344 }; -345 -346 /** -347 * Function that installs a spy on an existing object's method name. Used within a Spec to create a spy. +324 var spy = new jasmine.Spy(name); +325 +326 for (var prop in spy) { +327 spyObj[prop] = spy[prop]; +328 } +329 +330 spyObj.reset(); +331 +332 return spyObj; +333 }; +334 +335 /** +336 * Determines whether an object is a spy. +337 * +338 * @param {jasmine.Spy|Object} putativeSpy +339 * @returns {Boolean} +340 */ +341 jasmine.isSpy = function(putativeSpy) { +342 return putativeSpy && putativeSpy.isSpy; +343 }; +344 +345 /** +346 * Creates a more complicated spy: an Object that has every property a function that is a spy. Used for stubbing something +347 * large in one call. 348 * -349 * @example -350 * // spy example -351 * var foo = { -352 * not: function(bool) { return !bool; } -353 * } -354 * spyOn(foo, 'not'); // actual foo.not will not be called, execution stops -355 * -356 * @see jasmine.createSpy -357 * @param obj -358 * @param methodName -359 * @returns a Jasmine spy that can be chained with all spy methods -360 */ -361 var spyOn = function(obj, methodName) { -362 return jasmine.getEnv().currentSpec.spyOn(obj, methodName); -363 }; -364 -365 /** -366 * Creates a Jasmine spec that will be added to the current suite. -367 * -368 * // TODO: pending tests -369 * -370 * @example -371 * it('should be true', function() { -372 * expect(true).toEqual(true); -373 * }); -374 * -375 * @param {String} desc description of this specification -376 * @param {Function} func defines the preconditions and expectations of the spec -377 */ -378 var it = function(desc, func) { -379 return jasmine.getEnv().it(desc, func); -380 }; -381 -382 /** -383 * Creates a <em>disabled</em> Jasmine spec. -384 * -385 * A convenience method that allows existing specs to be disabled temporarily during development. -386 * -387 * @param {String} desc description of this specification -388 * @param {Function} func defines the preconditions and expectations of the spec -389 */ -390 var xit = function(desc, func) { -391 return jasmine.getEnv().xit(desc, func); -392 }; -393 -394 /** -395 * Starts a chain for a Jasmine expectation. -396 * -397 * It is passed an Object that is the actual value and should chain to one of the many -398 * jasmine.Matchers functions. -399 * -400 * @param {Object} actual Actual value to test against and expected value -401 */ -402 var expect = function(actual) { -403 return jasmine.getEnv().currentSpec.expect(actual); -404 }; -405 -406 /** -407 * Defines part of a jasmine spec. Used in cominbination with waits or waitsFor in asynchrnous specs. -408 * -409 * @param {Function} func Function that defines part of a jasmine spec. -410 */ -411 var runs = function(func) { -412 jasmine.getEnv().currentSpec.runs(func); -413 }; -414 -415 /** -416 * Waits for a timeout before moving to the next runs()-defined block. -417 * @param {Number} timeout -418 */ -419 var waits = function(timeout) { -420 jasmine.getEnv().currentSpec.waits(timeout); -421 }; -422 -423 /** -424 * Waits for the latchFunction to return true before proceeding to the next runs()-defined block. -425 * -426 * @param {Number} timeout -427 * @param {Function} latchFunction -428 * @param {String} message -429 */ -430 var waitsFor = function(timeout, latchFunction, message) { -431 jasmine.getEnv().currentSpec.waitsFor(timeout, latchFunction, message); -432 }; -433 -434 /** -435 * A function that is called before each spec in a suite. -436 * -437 * Used for spec setup, including validating assumptions. -438 * -439 * @param {Function} beforeEachFunction -440 */ -441 var beforeEach = function(beforeEachFunction) { -442 jasmine.getEnv().beforeEach(beforeEachFunction); -443 }; -444 -445 /** -446 * A function that is called after each spec in a suite. -447 * -448 * Used for restoring any state that is hijacked during spec execution. -449 * -450 * @param {Function} afterEachFunction -451 */ -452 var afterEach = function(afterEachFunction) { -453 jasmine.getEnv().afterEach(afterEachFunction); -454 }; -455 -456 /** -457 * Defines a suite of specifications. -458 * -459 * Stores the description and all defined specs in the Jasmine environment as one suite of specs. Variables declared -460 * are accessible by calls to beforeEach, it, and afterEach. Describe blocks can be nested, allowing for specialization -461 * of setup in some tests. -462 * -463 * @example -464 * // TODO: a simple suite +349 * @param {String} baseName name of spy class +350 * @param {Array} methodNames array of names of methods to make spies +351 */ +352 jasmine.createSpyObj = function(baseName, methodNames) { +353 var obj = {}; +354 for (var i = 0; i < methodNames.length; i++) { +355 obj[methodNames[i]] = jasmine.createSpy(baseName + '.' + methodNames[i]); +356 } +357 return obj; +358 }; +359 +360 jasmine.log = function(message) { +361 jasmine.getEnv().currentSpec.log(message); +362 }; +363 +364 /** +365 * Function that installs a spy on an existing object's method name. Used within a Spec to create a spy. +366 * +367 * @example +368 * // spy example +369 * var foo = { +370 * not: function(bool) { return !bool; } +371 * } +372 * spyOn(foo, 'not'); // actual foo.not will not be called, execution stops +373 * +374 * @see jasmine.createSpy +375 * @param obj +376 * @param methodName +377 * @returns a Jasmine spy that can be chained with all spy methods +378 */ +379 var spyOn = function(obj, methodName) { +380 return jasmine.getEnv().currentSpec.spyOn(obj, methodName); +381 }; +382 +383 /** +384 * Creates a Jasmine spec that will be added to the current suite. +385 * +386 * // TODO: pending tests +387 * +388 * @example +389 * it('should be true', function() { +390 * expect(true).toEqual(true); +391 * }); +392 * +393 * @param {String} desc description of this specification +394 * @param {Function} func defines the preconditions and expectations of the spec +395 */ +396 var it = function(desc, func) { +397 return jasmine.getEnv().it(desc, func); +398 }; +399 +400 /** +401 * Creates a <em>disabled</em> Jasmine spec. +402 * +403 * A convenience method that allows existing specs to be disabled temporarily during development. +404 * +405 * @param {String} desc description of this specification +406 * @param {Function} func defines the preconditions and expectations of the spec +407 */ +408 var xit = function(desc, func) { +409 return jasmine.getEnv().xit(desc, func); +410 }; +411 +412 /** +413 * Starts a chain for a Jasmine expectation. +414 * +415 * It is passed an Object that is the actual value and should chain to one of the many +416 * jasmine.Matchers functions. +417 * +418 * @param {Object} actual Actual value to test against and expected value +419 */ +420 var expect = function(actual) { +421 return jasmine.getEnv().currentSpec.expect(actual); +422 }; +423 +424 /** +425 * Defines part of a jasmine spec. Used in cominbination with waits or waitsFor in asynchrnous specs. +426 * +427 * @param {Function} func Function that defines part of a jasmine spec. +428 */ +429 var runs = function(func) { +430 jasmine.getEnv().currentSpec.runs(func); +431 }; +432 +433 /** +434 * Waits for a timeout before moving to the next runs()-defined block. +435 * @param {Number} timeout +436 */ +437 var waits = function(timeout) { +438 jasmine.getEnv().currentSpec.waits(timeout); +439 }; +440 +441 /** +442 * Waits for the latchFunction to return true before proceeding to the next runs()-defined block. +443 * +444 * @param {Number} timeout +445 * @param {Function} latchFunction +446 * @param {String} message +447 */ +448 var waitsFor = function(timeout, latchFunction, message) { +449 jasmine.getEnv().currentSpec.waitsFor(timeout, latchFunction, message); +450 }; +451 +452 /** +453 * A function that is called before each spec in a suite. +454 * +455 * Used for spec setup, including validating assumptions. +456 * +457 * @param {Function} beforeEachFunction +458 */ +459 var beforeEach = function(beforeEachFunction) { +460 jasmine.getEnv().beforeEach(beforeEachFunction); +461 }; +462 +463 /** +464 * A function that is called after each spec in a suite. 465 * -466 * // TODO: a simple suite with a nested describe block +466 * Used for restoring any state that is hijacked during spec execution. 467 * -468 * @param {String} description A string, usually the class under test. -469 * @param {Function} specDefinitions function that defines several specs. -470 */ -471 var describe = function(description, specDefinitions) { -472 return jasmine.getEnv().describe(description, specDefinitions); -473 }; -474 -475 /** -476 * Disables a suite of specifications. Used to disable some suites in a file, or files, temporarily during development. -477 * -478 * @param {String} description A string, usually the class under test. -479 * @param {Function} specDefinitions function that defines several specs. -480 */ -481 var xdescribe = function(description, specDefinitions) { -482 return jasmine.getEnv().xdescribe(description, specDefinitions); -483 }; -484 -485 -486 jasmine.XmlHttpRequest = XMLHttpRequest; -487 -488 // Provide the XMLHttpRequest class for IE 5.x-6.x: -489 if (typeof XMLHttpRequest == "undefined") jasmine.XmlHttpRequest = function() { -490 try { -491 return new ActiveXObject("Msxml2.XMLHTTP.6.0"); -492 } catch(e) { -493 } -494 try { -495 return new ActiveXObject("Msxml2.XMLHTTP.3.0"); -496 } catch(e) { -497 } -498 try { -499 return new ActiveXObject("Msxml2.XMLHTTP"); -500 } catch(e) { -501 } -502 try { -503 return new ActiveXObject("Microsoft.XMLHTTP"); -504 } catch(e) { -505 } -506 throw new Error("This browser does not support XMLHttpRequest."); -507 }; -508 -509 /** -510 * Adds suite files to an HTML document so that they are executed, thus adding them to the current -511 * Jasmine environment. -512 * -513 * @param {String} url path to the file to include -514 * @param {Boolean} opt_global -515 */ -516 jasmine.include = function(url, opt_global) { -517 if (opt_global) { -518 document.write('<script type="text/javascript" src="' + url + '"></' + 'script>'); -519 } else { -520 var xhr; -521 try { -522 xhr = new jasmine.XmlHttpRequest(); -523 xhr.open("GET", url, false); -524 xhr.send(null); -525 } catch(e) { -526 throw new Error("couldn't fetch " + url + ": " + e); -527 } -528 -529 return eval(xhr.responseText); -530 } -531 }; -532 \ No newline at end of file +468 * @param {Function} afterEachFunction +469 */ +470 var afterEach = function(afterEachFunction) { +471 jasmine.getEnv().afterEach(afterEachFunction); +472 }; +473 +474 /** +475 * Defines a suite of specifications. +476 * +477 * Stores the description and all defined specs in the Jasmine environment as one suite of specs. Variables declared +478 * are accessible by calls to beforeEach, it, and afterEach. Describe blocks can be nested, allowing for specialization +479 * of setup in some tests. +480 * +481 * @example +482 * // TODO: a simple suite +483 * +484 * // TODO: a simple suite with a nested describe block +485 * +486 * @param {String} description A string, usually the class under test. +487 * @param {Function} specDefinitions function that defines several specs. +488 */ +489 var describe = function(description, specDefinitions) { +490 return jasmine.getEnv().describe(description, specDefinitions); +491 }; +492 +493 /** +494 * Disables a suite of specifications. Used to disable some suites in a file, or files, temporarily during development. +495 * +496 * @param {String} description A string, usually the class under test. +497 * @param {Function} specDefinitions function that defines several specs. +498 */ +499 var xdescribe = function(description, specDefinitions) { +500 return jasmine.getEnv().xdescribe(description, specDefinitions); +501 }; +502 +503 +504 // Provide the XMLHttpRequest class for IE 5.x-6.x: +505 jasmine.XmlHttpRequest = (typeof XMLHttpRequest == "undefined") ? function() { +506 try { +507 return new ActiveXObject("Msxml2.XMLHTTP.6.0"); +508 } catch(e) { +509 } +510 try { +511 return new ActiveXObject("Msxml2.XMLHTTP.3.0"); +512 } catch(e) { +513 } +514 try { +515 return new ActiveXObject("Msxml2.XMLHTTP"); +516 } catch(e) { +517 } +518 try { +519 return new ActiveXObject("Microsoft.XMLHTTP"); +520 } catch(e) { +521 } +522 throw new Error("This browser does not support XMLHttpRequest."); +523 } : XMLHttpRequest; +524 +525 /** +526 * Adds suite files to an HTML document so that they are executed, thus adding them to the current +527 * Jasmine environment. +528 * +529 * @param {String} url path to the file to include +530 * @param {Boolean} opt_global +531 */ +532 jasmine.include = function(url, opt_global) { +533 if (opt_global) { +534 document.write('<script type="text/javascript" src="' + url + '"></' + 'script>'); +535 } else { +536 var xhr; +537 try { +538 xhr = new jasmine.XmlHttpRequest(); +539 xhr.open("GET", url, false); +540 xhr.send(null); +541 } catch(e) { +542 throw new Error("couldn't fetch " + url + ": " + e); +543 } +544 +545 return eval(xhr.responseText); +546 } +547 }; +548 \ No newline at end of file diff --git a/doc/symbols/src/src_mock-timeout.js.html b/doc/symbols/src/src_mock-timeout.js.html index 48e5382..664a3c3 100644 --- a/doc/symbols/src/src_mock-timeout.js.html +++ b/doc/symbols/src/src_mock-timeout.js.html @@ -25,11 +25,11 @@ 18 }; 19 20 self.clearTimeout = function(timeoutKey) { - 21 self.scheduledFunctions[timeoutKey] = undefined; + 21 self.scheduledFunctions[timeoutKey] = jasmine.undefined; 22 }; 23 24 self.clearInterval = function(timeoutKey) { - 25 self.scheduledFunctions[timeoutKey] = undefined; + 25 self.scheduledFunctions[timeoutKey] = jasmine.undefined; 26 }; 27 28 }; @@ -52,11 +52,11 @@ 45 var funcsToRun = []; 46 for (var timeoutKey in this.scheduledFunctions) { 47 scheduledFunc = this.scheduledFunctions[timeoutKey]; - 48 if (scheduledFunc != undefined && + 48 if (scheduledFunc != jasmine.undefined && 49 scheduledFunc.runAtMillis >= oldMillis && 50 scheduledFunc.runAtMillis <= nowMillis) { 51 funcsToRun.push(scheduledFunc); - 52 this.scheduledFunctions[timeoutKey] = undefined; + 52 this.scheduledFunctions[timeoutKey] = jasmine.undefined; 53 } 54 } 55 diff --git a/examples/ruby/spec/jasmine_spec.rb b/examples/ruby/spec/jasmine_spec.rb index 1b37d8b..de4f09f 100644 --- a/examples/ruby/spec/jasmine_spec.rb +++ b/examples/ruby/spec/jasmine_spec.rb @@ -11,7 +11,7 @@ jasmine_runner = if ENV['SAUCELABS'] == 'true' :saucelabs_config_file => File.expand_path(File.join(File.dirname(__FILE__), "saucelabs.yml"))) else require "selenium_rc" - Jasmine::Runner.new(SeleniumRC::Server.new.jar_path, + Jasmine::Runner.new(SeleniumRC::Server.new('localhost').jar_path, JasmineHelper.specs, JasmineHelper.dir_mappings) end diff --git a/geminstaller.yml b/geminstaller.yml index a89fb78..56267f2 100644 --- a/geminstaller.yml +++ b/geminstaller.yml @@ -6,8 +6,8 @@ gems: version: 0.0.2.1 - name: json version: 1.1.9 -- name: pivotal-selenium-rc - version: 1.11.20090610 +- name: selenium-rc + version: 2.1.0 - name: rack version: 1.0.0 - name: thin diff --git a/lib/jasmine-0.10.0.js b/lib/jasmine-0.10.0.js index bfb4494..850daae 100644 --- a/lib/jasmine-0.10.0.js +++ b/lib/jasmine-0.10.0.js @@ -2255,5 +2255,5 @@ jasmine.version_= { "major": 0, "minor": 10, "build": 0, - "revision": 1261582590 + "revision": 1261632445 }; diff --git a/spec/jasmine_spec.rb b/spec/jasmine_spec.rb index 1b37d8b..de4f09f 100644 --- a/spec/jasmine_spec.rb +++ b/spec/jasmine_spec.rb @@ -11,7 +11,7 @@ jasmine_runner = if ENV['SAUCELABS'] == 'true' :saucelabs_config_file => File.expand_path(File.join(File.dirname(__FILE__), "saucelabs.yml"))) else require "selenium_rc" - Jasmine::Runner.new(SeleniumRC::Server.new.jar_path, + Jasmine::Runner.new(SeleniumRC::Server.new('localhost').jar_path, JasmineHelper.specs, JasmineHelper.dir_mappings) end