Commit 47b368be 47b368be5fab6ac9fe17d5c923384f44ba7d8127 by Nicolas Perriault

added Casper.Tester.assertRaises()

1 parent a2420455
Showing 1 changed file with 25 additions and 1 deletions
...@@ -113,9 +113,15 @@ ...@@ -113,9 +113,15 @@
113 * @return Casper 113 * @return Casper
114 */ 114 */
115 capture: function(targetFile, clipRect) { 115 capture: function(targetFile, clipRect) {
116 if (typeof clipRect !== "object") {
117 throw new Error("ClipRect must be an object instance.");
118 }
116 var previousClipRect = this.page.clipRect; 119 var previousClipRect = this.page.clipRect;
117 if (clipRect) { 120 if (clipRect) {
118 this.page.clipRect = clipRect; 121 this.page.clipRect = clipRect;
122 this.log('Capturing page to ' + targetFile + ' with clipRect' + JSON.stringify(clipRect), "debug");
123 } else {
124 this.log('Capturing page to ' + targetFile, "debug");
119 } 125 }
120 if (!this.page.render(targetFile)) { 126 if (!this.page.render(targetFile)) {
121 this.log('Failed to capture screenshot as ' + targetFile, "error"); 127 this.log('Failed to capture screenshot as ' + targetFile, "error");
...@@ -1262,6 +1268,23 @@ ...@@ -1262,6 +1268,23 @@
1262 }; 1268 };
1263 1269
1264 /** 1270 /**
1271 * Asserts that the provided function called with the given parameters
1272 * will raise an exception.
1273 *
1274 * @param Function fn The function to test
1275 * @param Array args The arguments to pass to the function
1276 * @param String message Test description
1277 */
1278 this.assertRaises = function(fn, args, message) {
1279 try {
1280 fn.apply(null, args);
1281 this.fail(message);
1282 } catch (e) {
1283 this.pass(message);
1284 }
1285 };
1286
1287 /**
1265 * Asserts that at least an element matching the provided CSS3 selector 1288 * Asserts that at least an element matching the provided CSS3 selector
1266 * exists in remote DOM. 1289 * exists in remote DOM.
1267 * 1290 *
...@@ -1471,7 +1494,8 @@ ...@@ -1471,7 +1494,8 @@
1471 }; 1494 };
1472 1495
1473 /** 1496 /**
1474 * Provides a better typeof operator equivalent 1497 * Provides a better typeof operator equivalent, able to retrieve the array
1498 * type.
1475 * 1499 *
1476 * @param mixed input 1500 * @param mixed input
1477 * @return String 1501 * @return String
......