Skip to content

Commit

Permalink
Releasing 1.3
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
Davis W. Frank & Rajan Agaskar committed Nov 27, 2012
1 parent 74cdc5a commit 867de62
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 25 deletions.
2 changes: 1 addition & 1 deletion lib/jasmine-core/jasmine-html.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ jasmine.HtmlReporter = function(_doc) {
dom.symbolSummary = self.createDom('ul', {className: 'symbolSummary'}),
dom.alert = self.createDom('div', {className: 'alert'},
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' }))),
dom.results = self.createDom('div', {className: 'results'},
dom.summary = self.createDom('div', { className: 'summary' }),
Expand Down
45 changes: 27 additions & 18 deletions lib/jasmine-core/jasmine.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ jasmine.VERBOSE = false;
*/
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.
*/
Expand Down Expand Up @@ -470,7 +475,7 @@ jasmine.log = function() {
* @see jasmine.createSpy
* @param obj
* @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) {
return jasmine.getEnv().currentSpec.spyOn(obj, methodName);
Expand Down Expand Up @@ -515,6 +520,7 @@ if (isCommonJS) exports.xit = xit;
* jasmine.Matchers functions.
*
* @param {Object} actual Actual value to test against and expected value
* @return {jasmine.Matchers}
*/
var expect = function(actual) {
return jasmine.getEnv().currentSpec.expect(actual);
Expand Down Expand Up @@ -1404,18 +1410,14 @@ jasmine.Matchers.prototype.toHaveBeenCalledWith = function() {
throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');
}
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) {
// todo: what should the failure message for .not.toHaveBeenCalledWith() be? is this right? test better. [xw]
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."
];
positiveMessage = "Expected spy " + this.actual.identity + " to have been called with " + jasmine.pp(expectedArgs) + " but it was never called.";
} else {
return [
"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)
];
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, '')
}
return [positiveMessage, invertedMessage];
};

return this.env.contains_(this.actual.argsForCall, expectedArgs);
Expand Down Expand Up @@ -1473,7 +1475,7 @@ jasmine.Matchers.prototype.toBeGreaterThan = function(expected) {
* up to a given level of decimal precision (default 2).
*
* @param {Number} expected
* @param {Number} precision
* @param {Number} precision, as number of decimal places
*/
jasmine.Matchers.prototype.toBeCloseTo = function(expected, precision) {
if (!(precision === 0)) {
Expand All @@ -1485,7 +1487,7 @@ jasmine.Matchers.prototype.toBeCloseTo = function(expected, precision) {
/**
* Matcher that checks that the expected exception was thrown by the actual.
*
* @param {String} expected
* @param {String} [expected]
*/
jasmine.Matchers.prototype.toThrow = function(expected) {
var result = false;
Expand Down Expand Up @@ -1883,10 +1885,6 @@ jasmine.PrettyPrinter = function() {
* @param value
*/
jasmine.PrettyPrinter.prototype.format = function(value) {
if (this.ppNestLevel_ > 40) {
throw new Error('jasmine.PrettyPrinter: format() nested too deeply!');
}

this.ppNestLevel_++;
try {
if (value === jasmine.undefined) {
Expand Down Expand Up @@ -1929,6 +1927,7 @@ jasmine.PrettyPrinter.prototype.format = function(value) {

jasmine.PrettyPrinter.prototype.iterateObject = function(obj, fn) {
for (var property in obj) {
if (!obj.hasOwnProperty(property)) continue;
if (property == '__Jasmine_been_here_before__') continue;
fn(property, obj.__lookupGetter__ ? (obj.__lookupGetter__(property) !== jasmine.undefined &&
obj.__lookupGetter__(property) !== null) : false);
Expand Down Expand Up @@ -1956,6 +1955,11 @@ jasmine.StringPrettyPrinter.prototype.emitString = function(value) {
};

jasmine.StringPrettyPrinter.prototype.emitArray = function(array) {
if (this.ppNestLevel_ > jasmine.MAX_PRETTY_PRINT_DEPTH) {
this.append("Array");
return;
}

this.append('[ ');
for (var i = 0; i < array.length; i++) {
if (i > 0) {
Expand All @@ -1967,6 +1971,11 @@ jasmine.StringPrettyPrinter.prototype.emitArray = function(array) {
};

jasmine.StringPrettyPrinter.prototype.emitObject = function(obj) {
if (this.ppNestLevel_ > jasmine.MAX_PRETTY_PRINT_DEPTH) {
this.append("Object");
return;
}

var self = this;
this.append('{ ');
var first = true;
Expand Down Expand Up @@ -2585,7 +2594,7 @@ jasmine.WaitsForBlock.prototype.execute = function(onComplete) {

jasmine.version_= {
"major": 1,
"minor": 2,
"minor": 3,
"build": 0,
"revision": 1343710612
"revision": 1354052693
};
2 changes: 1 addition & 1 deletion lib/jasmine-core/version.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Jasmine
module Core
VERSION = "1.2.0"
VERSION = "1.3.0"
end
end

2 changes: 1 addition & 1 deletion pages
Submodule pages updated from 39dcf8 to 00ba05
2 changes: 1 addition & 1 deletion src/core/Matchers.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ jasmine.Matchers.prototype.toBeGreaterThan = function(expected) {
* up to a given level of decimal precision (default 2).
*
* @param {Number} expected
* @param {Number} precision
* @param {Number} precision, as number of decimal places
*/
jasmine.Matchers.prototype.toBeCloseTo = function(expected, precision) {
if (!(precision === 0)) {
Expand Down
4 changes: 2 additions & 2 deletions src/version.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

jasmine.version_= {
"major": 1,
"minor": 2,
"minor": 3,
"build": 0,
"revision": 1343710612
"revision": 1354052693
};
2 changes: 1 addition & 1 deletion src/version.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"major": 1,
"minor": 2,
"minor": 3,
"build": 0
}

0 comments on commit 867de62

Please sign in to comment.