Commit 6c726eeb 6c726eebedd4a8cd768c29420338c6bfa6009247 by Nicolas Perriault

updated assertion processing system

1 parent 37cbe2c3
...@@ -82,6 +82,7 @@ var Tester = function Tester(casper, options) { ...@@ -82,6 +82,7 @@ var Tester = function Tester(casper, options) {
82 // special printing 82 // special printing
83 switch (failure.type) { 83 switch (failure.type) {
84 case 'assertEquals': 84 case 'assertEquals':
85 case 'assertEvalEquals':
85 this.comment(' got: ' + utils.serialize(failure.values.subject)); 86 this.comment(' got: ' + utils.serialize(failure.values.subject));
86 this.comment(' expected: ' + utils.serialize(failure.values.expected)); 87 this.comment(' expected: ' + utils.serialize(failure.values.expected));
87 break; 88 break;
...@@ -163,9 +164,20 @@ var Tester = function Tester(casper, options) { ...@@ -163,9 +164,20 @@ var Tester = function Tester(casper, options) {
163 * @param Function fn A function to be evaluated in remote DOM 164 * @param Function fn A function to be evaluated in remote DOM
164 * @param String message Test description 165 * @param String message Test description
165 * @param Object params Object containing the parameters to inject into the function (optional) 166 * @param Object params Object containing the parameters to inject into the function (optional)
167 * @param Object|null context Assertion context object (Optional)
166 */ 168 */
167 this.assertEval = function assertEval(fn, message, params, context) { 169 this.assertEval = this.assertEvaluate = function assertEval(fn, message, params, context) {
168 return this.assert(casper.evaluate(fn, params), message, context); 170 return this.processAssertionResult(utils.mergeObjects({
171 success: casper.evaluate(fn, params),
172 type: "assertEval",
173 details: "function didn't evaluate to true",
174 message: message,
175 file: this.currentTestFile,
176 values: {
177 fn: fn,
178 params: params
179 }
180 }, context || {}));
169 }; 181 };
170 182
171 /** 183 /**
...@@ -174,11 +186,22 @@ var Tester = function Tester(casper, options) { ...@@ -174,11 +186,22 @@ var Tester = function Tester(casper, options) {
174 * 186 *
175 * @param Function fn The function to be evaluated in remote DOM 187 * @param Function fn The function to be evaluated in remote DOM
176 * @param Boolean expected The expected value 188 * @param Boolean expected The expected value
177 * @param String message Test description 189 * @param String|null message Test description
178 * @param Object params Object containing the parameters to inject into the function (optional) 190 * @param Object|null params Object containing the parameters to inject into the function (optional)
191 * @param Object|null context Assertion context object (Optional)
179 */ 192 */
180 this.assertEvalEquals = this.assertEvalEqual = function assertEvalEquals(fn, expected, message, context) { 193 this.assertEvalEquals = this.assertEvalEqual = function assertEvalEquals(fn, expected, message, params, context) {
181 return this.assertEquals(casper.evaluate(fn, context), expected, message); 194 return this.processAssertionResult(utils.mergeObjects({
195 success: this.testEquals(casper.evaluate(fn, params), expected),
196 type: "assertEvalEquals",
197 details: f("test failed; expected: %s; got: %s", expected, subject),
198 message: message,
199 file: this.currentTestFile,
200 values: {
201 subject: subject,
202 expected: expected
203 }
204 }, context || {}));
182 }; 205 };
183 206
184 /** 207 /**
......