diff --git a/lib/vows/console.js b/lib/vows/console.js index 4a33141..f4e8e29 100644 --- a/lib/vows/console.js +++ b/lib/vows/console.js @@ -97,3 +97,35 @@ this.error = function (obj) { return string; }; + +this.contextText = function (event) { + return ' ' + event; +}; + +this.vowText = function (event) { + var buffer = []; + + buffer.push(' ' + { + honored: ' ✓ ', + broken: ' ✗ ', + errored: ' ✗ ', + pending: ' - ' + }[event.status] + stylize(event.title, ({ + honored: 'green', + broken: 'yellow', + errored: 'red', + pending: 'cyan' + })[event.status])); + + if (event.status === 'broken') { + buffer.push(' » ' + event.exception); + } else if (event.status === 'errored') { + if (event.exception.type === 'promise') { + buffer.push(' » ' + stylize("An unexpected error was caught: " + + stylize(event.exception.error, 'bold'), 'red')); + } else { + buffer.push(' ' + stylize(event.exception, 'red')); + } + } + return buffer.join('\n'); +}; diff --git a/lib/vows/reporters/dot-matrix.js b/lib/vows/reporters/dot-matrix.js index 9bb3d1e..0ecf590 100644 --- a/lib/vows/reporters/dot-matrix.js +++ b/lib/vows/reporters/dot-matrix.js @@ -37,10 +37,10 @@ this.report = function (data) { } if (event.status === 'broken') { puts(stylize('✗', 'yellow')); - messages.push(spec.vowText(event)); + messages.push(console.vowText(event)); } else if (event.status === 'errored') { puts(stylize('✗', 'red')); - messages.push(spec.vowText(event)); + messages.push(console.vowText(event)); } messages.push(''); } diff --git a/lib/vows/reporters/spec.js b/lib/vows/reporters/spec.js index 8f88529..0f91146 100644 --- a/lib/vows/reporters/spec.js +++ b/lib/vows/reporters/spec.js @@ -22,10 +22,10 @@ this.report = function (data) { puts('\n♢ ' + stylize(event, 'bold') + '\n'); break; case 'context': - puts(this.contextText(event)); + puts(console.contextText(event)); break; case 'vow': - puts(this.vowText(event)); + puts(console.vowText(event)); break; case 'end': sys.print('\n'); @@ -39,38 +39,6 @@ this.report = function (data) { } }; -this.contextText = function (event) { - return ' ' + event; -}; - -this.vowText = function (event) { - var buffer = []; - - buffer.push(' ' + { - honored: ' ✓ ', - broken: ' ✗ ', - errored: ' ✗ ', - pending: ' - ' - }[event.status] + stylize(event.title, ({ - honored: 'green', - broken: 'yellow', - errored: 'red', - pending: 'cyan' - })[event.status])); - - if (event.status === 'broken') { - buffer.push(' » ' + event.exception); - } else if (event.status === 'errored') { - if (event.exception.type === 'promise') { - buffer.push(' » ' + stylize("An unexpected error was caught: " + - stylize(event.exception.error, 'bold'), 'red')); - } else { - buffer.push(' ' + stylize(event.exception, 'red')); - } - } - return buffer.join('\n'); -}; - this.print = function (str) { sys.print(str); }; diff --git a/lib/vows/reporters/watch.js b/lib/vows/reporters/watch.js index 36ae927..f172481 100644 --- a/lib/vows/reporters/watch.js +++ b/lib/vows/reporters/watch.js @@ -25,9 +25,9 @@ this.report = function (data) { if (['honored', 'pending'].indexOf(event.status) === -1) { if (lastContext !== event.context) { lastContext = event.context; - puts(spec.contextText(event.context)); + puts(console.contextText(event.context)); } - puts(spec.vowText(event)); + puts(console.vowText(event)); puts(''); } break;