Releasing 1.3

- Allow users to set the pretty-printer's recursion depth
- When pretty-printing objects, don't include inherited properties.
- Change toBeCloseTo matcher to be more consistent
- Added toBeNaN matcher
- Add checkbox to test runner which toggles catching of exceptions duri
- Add config option which stops jasmine from capturing exceptions in a
This commit is contained in:
Davis W. Frank & Rajan Agaskar
2012-11-27 13:47:02 -08:00
parent e3a013ae99
commit 9a7c76ea23
7 changed files with 34 additions and 25 deletions

View File

@@ -154,7 +154,7 @@ jasmine.HtmlReporter = function(_doc) {
dom.symbolSummary = self.createDom('ul', {className: 'symbolSummary'}), dom.symbolSummary = self.createDom('ul', {className: 'symbolSummary'}),
dom.alert = self.createDom('div', {className: 'alert'}, dom.alert = self.createDom('div', {className: 'alert'},
self.createDom('span', { className: 'exceptions' }, self.createDom('span', { className: 'exceptions' },
self.createDom('label', { className: 'label', 'for': 'no_try_catch' }, 'No try/catch'), self.createDom('label', { className: 'label', for: 'no_try_catch' }, 'No try/catch'),
self.createDom('input', { id: 'no_try_catch', type: 'checkbox' }))), self.createDom('input', { id: 'no_try_catch', type: 'checkbox' }))),
dom.results = self.createDom('div', {className: 'results'}, dom.results = self.createDom('div', {className: 'results'},
dom.summary = self.createDom('div', { className: 'summary' }), dom.summary = self.createDom('div', { className: 'summary' }),

View File

@@ -34,6 +34,11 @@ jasmine.VERBOSE = false;
*/ */
jasmine.DEFAULT_UPDATE_INTERVAL = 250; jasmine.DEFAULT_UPDATE_INTERVAL = 250;
/**
* Maximum levels of nesting that will be included when an object is pretty-printed
*/
jasmine.MAX_PRETTY_PRINT_DEPTH = 40;
/** /**
* Default timeout interval in milliseconds for waitsFor() blocks. * Default timeout interval in milliseconds for waitsFor() blocks.
*/ */
@@ -470,7 +475,7 @@ jasmine.log = function() {
* @see jasmine.createSpy * @see jasmine.createSpy
* @param obj * @param obj
* @param methodName * @param methodName
* @returns a Jasmine spy that can be chained with all spy methods * @return {jasmine.Spy} a Jasmine spy that can be chained with all spy methods
*/ */
var spyOn = function(obj, methodName) { var spyOn = function(obj, methodName) {
return jasmine.getEnv().currentSpec.spyOn(obj, methodName); return jasmine.getEnv().currentSpec.spyOn(obj, methodName);
@@ -515,6 +520,7 @@ if (isCommonJS) exports.xit = xit;
* jasmine.Matchers functions. * jasmine.Matchers functions.
* *
* @param {Object} actual Actual value to test against and expected value * @param {Object} actual Actual value to test against and expected value
* @return {jasmine.Matchers}
*/ */
var expect = function(actual) { var expect = function(actual) {
return jasmine.getEnv().currentSpec.expect(actual); return jasmine.getEnv().currentSpec.expect(actual);
@@ -1404,18 +1410,14 @@ jasmine.Matchers.prototype.toHaveBeenCalledWith = function() {
throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.'); throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');
} }
this.message = function() { this.message = function() {
var invertedMessage = "Expected spy " + this.actual.identity + " not to have been called with " + jasmine.pp(expectedArgs) + " but it was.";
var positiveMessage = "";
if (this.actual.callCount === 0) { if (this.actual.callCount === 0) {
// todo: what should the failure message for .not.toHaveBeenCalledWith() be? is this right? test better. [xw] positiveMessage = "Expected spy " + this.actual.identity + " to have been called with " + jasmine.pp(expectedArgs) + " but it was never called.";
return [
"Expected spy " + this.actual.identity + " to have been called with " + jasmine.pp(expectedArgs) + " but it was never called.",
"Expected spy " + this.actual.identity + " not to have been called with " + jasmine.pp(expectedArgs) + " but it was."
];
} else { } else {
return [ positiveMessage = "Expected spy " + this.actual.identity + " to have been called with " + jasmine.pp(expectedArgs) + " but actual calls were " + jasmine.pp(this.actual.argsForCall).replace(/^\[ | \]$/g, '')
"Expected spy " + this.actual.identity + " to have been called with " + jasmine.pp(expectedArgs) + " but was called with " + jasmine.pp(this.actual.argsForCall),
"Expected spy " + this.actual.identity + " not to have been called with " + jasmine.pp(expectedArgs) + " but was called with " + jasmine.pp(this.actual.argsForCall)
];
} }
return [positiveMessage, invertedMessage];
}; };
return this.env.contains_(this.actual.argsForCall, expectedArgs); return this.env.contains_(this.actual.argsForCall, expectedArgs);
@@ -1473,7 +1475,7 @@ jasmine.Matchers.prototype.toBeGreaterThan = function(expected) {
* up to a given level of decimal precision (default 2). * up to a given level of decimal precision (default 2).
* *
* @param {Number} expected * @param {Number} expected
* @param {Number} precision * @param {Number} precision, as number of decimal places
*/ */
jasmine.Matchers.prototype.toBeCloseTo = function(expected, precision) { jasmine.Matchers.prototype.toBeCloseTo = function(expected, precision) {
if (!(precision === 0)) { if (!(precision === 0)) {
@@ -1485,7 +1487,7 @@ jasmine.Matchers.prototype.toBeCloseTo = function(expected, precision) {
/** /**
* Matcher that checks that the expected exception was thrown by the actual. * Matcher that checks that the expected exception was thrown by the actual.
* *
* @param {String} expected * @param {String} [expected]
*/ */
jasmine.Matchers.prototype.toThrow = function(expected) { jasmine.Matchers.prototype.toThrow = function(expected) {
var result = false; var result = false;
@@ -1883,10 +1885,6 @@ jasmine.PrettyPrinter = function() {
* @param value * @param value
*/ */
jasmine.PrettyPrinter.prototype.format = function(value) { jasmine.PrettyPrinter.prototype.format = function(value) {
if (this.ppNestLevel_ > 40) {
throw new Error('jasmine.PrettyPrinter: format() nested too deeply!');
}
this.ppNestLevel_++; this.ppNestLevel_++;
try { try {
if (value === jasmine.undefined) { if (value === jasmine.undefined) {
@@ -1929,6 +1927,7 @@ jasmine.PrettyPrinter.prototype.format = function(value) {
jasmine.PrettyPrinter.prototype.iterateObject = function(obj, fn) { jasmine.PrettyPrinter.prototype.iterateObject = function(obj, fn) {
for (var property in obj) { for (var property in obj) {
if (!obj.hasOwnProperty(property)) continue;
if (property == '__Jasmine_been_here_before__') continue; if (property == '__Jasmine_been_here_before__') continue;
fn(property, obj.__lookupGetter__ ? (obj.__lookupGetter__(property) !== jasmine.undefined && fn(property, obj.__lookupGetter__ ? (obj.__lookupGetter__(property) !== jasmine.undefined &&
obj.__lookupGetter__(property) !== null) : false); obj.__lookupGetter__(property) !== null) : false);
@@ -1956,6 +1955,11 @@ jasmine.StringPrettyPrinter.prototype.emitString = function(value) {
}; };
jasmine.StringPrettyPrinter.prototype.emitArray = function(array) { jasmine.StringPrettyPrinter.prototype.emitArray = function(array) {
if (this.ppNestLevel_ > jasmine.MAX_PRETTY_PRINT_DEPTH) {
this.append("Array");
return;
}
this.append('[ '); this.append('[ ');
for (var i = 0; i < array.length; i++) { for (var i = 0; i < array.length; i++) {
if (i > 0) { if (i > 0) {
@@ -1967,6 +1971,11 @@ jasmine.StringPrettyPrinter.prototype.emitArray = function(array) {
}; };
jasmine.StringPrettyPrinter.prototype.emitObject = function(obj) { jasmine.StringPrettyPrinter.prototype.emitObject = function(obj) {
if (this.ppNestLevel_ > jasmine.MAX_PRETTY_PRINT_DEPTH) {
this.append("Object");
return;
}
var self = this; var self = this;
this.append('{ '); this.append('{ ');
var first = true; var first = true;
@@ -2585,7 +2594,7 @@ jasmine.WaitsForBlock.prototype.execute = function(onComplete) {
jasmine.version_= { jasmine.version_= {
"major": 1, "major": 1,
"minor": 2, "minor": 3,
"build": 0, "build": 0,
"revision": 1343710612 "revision": 1354052693
}; };

View File

@@ -1,6 +1,6 @@
module Jasmine module Jasmine
module Core module Core
VERSION = "1.2.0" VERSION = "1.3.0"
end end
end end

2
pages

Submodule pages updated: 39dcf87b56...00ba05c213

View File

@@ -303,7 +303,7 @@ jasmine.Matchers.prototype.toBeGreaterThan = function(expected) {
* up to a given level of decimal precision (default 2). * up to a given level of decimal precision (default 2).
* *
* @param {Number} expected * @param {Number} expected
* @param {Number} precision * @param {Number} precision, as number of decimal places
*/ */
jasmine.Matchers.prototype.toBeCloseTo = function(expected, precision) { jasmine.Matchers.prototype.toBeCloseTo = function(expected, precision) {
if (!(precision === 0)) { if (!(precision === 0)) {

View File

@@ -1,7 +1,7 @@
jasmine.version_= { jasmine.version_= {
"major": 1, "major": 1,
"minor": 2, "minor": 3,
"build": 0, "build": 0,
"revision": 1343710612 "revision": 1354052693
}; };

View File

@@ -1,5 +1,5 @@
{ {
"major": 1, "major": 1,
"minor": 2, "minor": 3,
"build": 0 "build": 0
} }