Commit 789f60d0 789f60d04e1090c3e5ed2ee3943528b9fb3bc8e5 by Nicolas Perriault

added colors to default test messages

1 parent 123f3128
...@@ -229,7 +229,7 @@ var Tester = function Tester(casper, options) { ...@@ -229,7 +229,7 @@ var Tester = function Tester(casper, options) {
229 this.assertExists = this.assertExist = this.assertSelectorExists = this.assertSelectorExist = function assertExists(selector, message) { 229 this.assertExists = this.assertExist = this.assertSelectorExists = this.assertSelectorExist = function assertExists(selector, message) {
230 return this.assert(casper.exists(selector), message, { 230 return this.assert(casper.exists(selector), message, {
231 type: "assertExists", 231 type: "assertExists",
232 standard: f("Found an element matching %s", selector), 232 standard: f("Found an element matching %s", this.colorize(selector, 'COMMENT')),
233 values: { 233 values: {
234 selector: selector 234 selector: selector
235 } 235 }
...@@ -247,7 +247,7 @@ var Tester = function Tester(casper, options) { ...@@ -247,7 +247,7 @@ var Tester = function Tester(casper, options) {
247 this.assertDoesntExist = this.assertNotExists = function assertDoesntExist(selector, message) { 247 this.assertDoesntExist = this.assertNotExists = function assertDoesntExist(selector, message) {
248 return this.assert(!casper.exists(selector), message, { 248 return this.assert(!casper.exists(selector), message, {
249 type: "assertDoesntExist", 249 type: "assertDoesntExist",
250 standard: f("No element matching selector %s is found", selector), 250 standard: f("No element matching selector %s is found", this.colorize(selector, 'COMMENT')),
251 values: { 251 values: {
252 selector: selector 252 selector: selector
253 } 253 }
...@@ -265,7 +265,7 @@ var Tester = function Tester(casper, options) { ...@@ -265,7 +265,7 @@ var Tester = function Tester(casper, options) {
265 var currentHTTPStatus = casper.currentHTTPStatus; 265 var currentHTTPStatus = casper.currentHTTPStatus;
266 return this.assert(this.testEquals(casper.currentHTTPStatus, status), message, { 266 return this.assert(this.testEquals(casper.currentHTTPStatus, status), message, {
267 type: "assertHttpStatus", 267 type: "assertHttpStatus",
268 standard: f("HTTP status code is %s", status), 268 standard: f("HTTP status code is %s", this.colorize(status, 'COMMENT')),
269 values: { 269 values: {
270 current: currentHTTPStatus, 270 current: currentHTTPStatus,
271 expected: status 271 expected: status
...@@ -383,7 +383,7 @@ var Tester = function Tester(casper, options) { ...@@ -383,7 +383,7 @@ var Tester = function Tester(casper, options) {
383 var currentTitle = casper.getTitle(); 383 var currentTitle = casper.getTitle();
384 return this.assert(this.testEquals(currentTitle, expected), message, { 384 return this.assert(this.testEquals(currentTitle, expected), message, {
385 type: "assertTitle", 385 type: "assertTitle",
386 standard: f('Page title is "%s"', expected), 386 standard: f('Page title is "%s"', this.colorize(expected, 'COMMENT')),
387 values: { 387 values: {
388 subject: currentTitle, 388 subject: currentTitle,
389 expected: expected 389 expected: expected
...@@ -403,7 +403,7 @@ var Tester = function Tester(casper, options) { ...@@ -403,7 +403,7 @@ var Tester = function Tester(casper, options) {
403 var actual = utils.betterTypeOf(subject); 403 var actual = utils.betterTypeOf(subject);
404 return this.assert(this.testEquals(actual, type), message, { 404 return this.assert(this.testEquals(actual, type), message, {
405 type: "assertType", 405 type: "assertType",
406 standard: f('Subject type is "%s"', type), 406 standard: f('Subject type is "%s"', this.colorize(type, 'COMMENT')),
407 values: { 407 values: {
408 subject: subject, 408 subject: subject,
409 type: type, 409 type: type,
...@@ -445,7 +445,7 @@ var Tester = function Tester(casper, options) { ...@@ -445,7 +445,7 @@ var Tester = function Tester(casper, options) {
445 * Casper.Colorizer#colorize() 445 * Casper.Colorizer#colorize()
446 */ 446 */
447 this.colorize = function colorize(message, style) { 447 this.colorize = function colorize(message, style) {
448 return casper.colorizer.colorize(message, style); 448 return casper.getColorizer().colorize(message, style);
449 }; 449 };
450 450
451 /** 451 /**
...@@ -535,7 +535,7 @@ var Tester = function Tester(casper, options) { ...@@ -535,7 +535,7 @@ var Tester = function Tester(casper, options) {
535 * @param String style 535 * @param String style
536 */ 536 */
537 this.formatMessage = function formatMessage(message, style) { 537 this.formatMessage = function formatMessage(message, style) {
538 var parts = /([a-z0-9_\.]+\(\))(.*)/i.exec(message); 538 var parts = /^([a-z0-9_\.]+\(\))(.*)/i.exec(message);
539 if (!parts) { 539 if (!parts) {
540 return message; 540 return message;
541 } 541 }
......