Permalink
Browse files

Group contexts by subject, consistent with success/pending events dis…

…play.
  • Loading branch information...
cliffano committed Dec 4, 2012
1 parent e26b290 commit 8334267d85770d262efe9677ed84775b858b56b8
Showing with 16 additions and 8 deletions.
  1. +16 −8 lib/vows/reporters/spec.js
View
@@ -4,7 +4,8 @@ var options = { tail: '\n' };
var console = require('../../vows/console');
var stylize = console.stylize,
puts = console.puts(options),
- summary = {};
+ summary = {},
+ currSubject;
//
// Console reporter
//
@@ -18,6 +19,7 @@ this.report = function (data) {
switch (data[0]) {
case 'subject':
+ currSubject = event;
puts('\n' + stylize(event, 'bold') + '\n');
break;
case 'context':
@@ -26,10 +28,13 @@ this.report = function (data) {
case 'vow':
if (event.status === 'broken' || event.status === 'errored') {
var context = event.context;
- if (summary[context]) {
- summary[context].push(event);
+ if (!summary[currSubject]) {
+ summary[currSubject] = {};
+ summary[currSubject][context] = [event];
+ } else if (!summary[currSubject][context]) {
+ summary[currSubject][context] = [event];
} else {
- summary[context] = [event];
+ summary[currSubject][context].push(event);
}
} else {
puts(console.vowText(event));
@@ -39,10 +44,13 @@ this.report = function (data) {
util.print('\n');
break;
case 'finish':
- Object.keys(summary).forEach(function (context) {
- puts(console.contextText(context));
- summary[context].forEach(function (event) {
- puts(console.vowText(event));
+ Object.keys(summary).forEach(function (subject) {
+ puts('\n' + stylize(subject, 'bold') + '\n');
+ Object.keys(summary[subject]).forEach(function (context) {
+ puts(console.contextText(context));
+ summary[subject][context].forEach(function (event) {
+ puts(console.vowText(event));
+ });
});
});
puts(console.result(event).join('\n'));

0 comments on commit 8334267

Please sign in to comment.