Skip to content

Commit

Permalink
(minor) Move .vowsText and .contextText out of reporters/spec into vo…
Browse files Browse the repository at this point in the history
…ws/console
  • Loading branch information
indexzero committed Aug 12, 2011
1 parent a813268 commit f18b45c
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 38 deletions.
32 changes: 32 additions & 0 deletions lib/vows/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
};
4 changes: 2 additions & 2 deletions lib/vows/reporters/dot-matrix.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('');
}
Expand Down
36 changes: 2 additions & 34 deletions lib/vows/reporters/spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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);
};
4 changes: 2 additions & 2 deletions lib/vows/reporters/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit f18b45c

Please sign in to comment.