Skip to content

Commit 73872a8

Browse files
committed
[fix doc] Remove all mentions of the word "promise", vows is based on the EventEmitter.
1 parent a8314b8 commit 73872a8

File tree

4 files changed

+30
-30
lines changed

4 files changed

+30
-30
lines changed

lib/vows.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ function addVow(vow) {
8888
if (vow.callback.length >= 2 || !batch.suite.options.error) {
8989
runTest(arguments, this.ctx);
9090
} else {
91-
output('errored', { type: 'promise', error: err.stack ||
91+
output('errored', { type: 'emitter', error: err.stack ||
9292
err.message || JSON.stringify(err) });
9393
}
9494
vows.tryEnd(batch);
@@ -162,7 +162,7 @@ function addVow(vow) {
162162
};
163163

164164
//
165-
// On exit, check that all promises have been fired.
165+
// On exit, check that all emitters have been fired.
166166
// If not, report an error message.
167167
//
168168
process.on('exit', function () {

lib/vows/console.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ this.vowText = function (event) {
131131
if (event.status === 'broken') {
132132
buffer.push(' » ' + event.exception);
133133
} else if (event.status === 'errored') {
134-
if (event.exception.type === 'promise') {
134+
if (event.exception.type === 'emitter') {
135135
buffer.push(' » ' + this.stylize("An unexpected error was caught: " +
136136
this.stylize(event.exception.error, 'bold'), 'red'));
137137
} else {

lib/vows/suite.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ this.Suite.prototype = new(function () {
5656
if ('topic' in tests) {
5757
throw new(Error)("missing top-level context.");
5858
}
59-
// Count the number of vows/promises expected to fire,
59+
// Count the number of vows/emitters expected to fire,
6060
// so we know when the tests are over.
6161
// We match the keys against `matcher`, to decide
6262
// whether or not they should be included in the test.
@@ -105,7 +105,7 @@ this.Suite.prototype = new(function () {
105105
this.runBatch = function (batch) {
106106
var topic,
107107
tests = batch.tests,
108-
promise = batch.promise = new(events.EventEmitter);
108+
emitter = batch.emitter = new(events.EventEmitter);
109109

110110
var that = this;
111111

@@ -117,7 +117,7 @@ this.Suite.prototype = new(function () {
117117
// arguments list.
118118
// It is defined and invoked at the same time.
119119
// If it encounters a `topic` function, it waits for the returned
120-
// promise to emit (the topic), at which point it runs the functions under it,
120+
// emitter to emit (the topic), at which point it runs the functions under it,
121121
// passing the topic as an argument.
122122
(function run(ctx, lastTopic) {
123123
var old = false;
@@ -152,7 +152,7 @@ this.Suite.prototype = new(function () {
152152
topic = lastTopic;
153153
}
154154

155-
// If the topic doesn't return an event emitter (such as a promise),
155+
// If the topic doesn't return an event emitter (such as an EventEmitter),
156156
// we create it ourselves, and emit the value on the next tick.
157157
if (! (topic &&
158158
topic.constructor === events.EventEmitter)) {
@@ -255,7 +255,7 @@ this.Suite.prototype = new(function () {
255255
exports.tryEnd(batch);
256256
// This is our initial, empty context
257257
})(new(Context)({ callback: tests, context: null, description: null }, {}));
258-
return promise;
258+
return emitter;
259259
};
260260

261261
this.report = function () {
@@ -395,7 +395,7 @@ this.tryEnd = function (batch) {
395395
function finish() {
396396
batch.status = 'end';
397397
batch.suite.report(['end']);
398-
batch.promise.emit('end', batch.honored, batch.broken, batch.errored, batch.pending);
398+
batch.emitter.emit('end', batch.honored, batch.broken, batch.errored, batch.pending);
399399
}
400400
}
401401
};

test/vows-test.js

+21-21
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,22 @@ var api = vows.prepare({
1111
version: function () { return '1.0' }
1212
}, ['get']);
1313

14-
var promiser = function (val) {
14+
var emitNextTick = function (val) {
1515
return function () {
16-
var promise = new(events.EventEmitter);
17-
process.nextTick(function () { promise.emit('success', val) });
18-
return promise;
16+
var emitter = new(events.EventEmitter);
17+
process.nextTick(function () { emitter.emit('success', val) });
18+
return emitter;
1919
}
2020
};
2121

2222
vows.describe("Vows").addBatch({
2323
"A context": {
24-
topic: promiser("hello world"),
24+
topic: emitNextTick("hello world"),
2525

2626
"with a nested context": {
2727
topic: function (parent) {
2828
this.state = 42;
29-
return promiser(parent)();
29+
return emitNextTick(parent)();
3030
},
3131
"has access to the environment": function () {
3232
assert.equal(this.state, 42);
@@ -47,24 +47,24 @@ vows.describe("Vows").addBatch({
4747
}
4848
},
4949
"A nested context": {
50-
topic: promiser(1),
50+
topic: emitNextTick(1),
5151

5252
".": {
53-
topic: function (a) { return promiser(2)() },
53+
topic: function (a) { return emitNextTick(2)() },
5454

5555
".": {
56-
topic: function (b, a) { return promiser(3)() },
56+
topic: function (b, a) { return emitNextTick(3)() },
5757

5858
".": {
59-
topic: function (c, b, a) { return promiser([4, c, b, a])() },
59+
topic: function (c, b, a) { return emitNextTick([4, c, b, a])() },
6060

6161
"should have access to the parent topics": function (topics) {
6262
assert.equal(topics.join(), [4, 3, 2, 1].join());
6363
}
6464
},
6565

6666
"from": {
67-
topic: function (c, b, a) { return promiser([4, c, b, a])() },
67+
topic: function (c, b, a) { return emitNextTick([4, c, b, a])() },
6868

6969
"the parent topics": function(topics) {
7070
assert.equal(topics.join(), [4, 3, 2, 1].join());
@@ -121,9 +121,9 @@ vows.describe("Vows").addBatch({
121121
}
122122
}
123123
},
124-
"A non-promise return value": {
124+
"A non-EventEmitter return value": {
125125
topic: function () { return 1 },
126-
"should be converted to a promise": function (val) {
126+
"should be converted to a vow": function (val) {
127127
assert.equal(val, 1);
128128
}
129129
},
@@ -173,11 +173,11 @@ vows.describe("Vows").addBatch({
173173
},
174174
"A topic emitting an error": {
175175
topic: function () {
176-
var promise = new(events.EventEmitter);
176+
var emitter = new(events.EventEmitter);
177177
process.nextTick(function () {
178-
promise.emit("error", 404);
178+
emitter.emit("error", 404);
179179
});
180-
return promise;
180+
return emitter;
181181
},
182182
"shouldn't raise an exception if the test expects it": function (e, res) {
183183
assert.equal(e, 404);
@@ -186,11 +186,11 @@ vows.describe("Vows").addBatch({
186186
},
187187
"A topic not emitting an error": {
188188
topic: function () {
189-
var promise = new(events.EventEmitter);
189+
var emitter = new(events.EventEmitter);
190190
process.nextTick(function () {
191-
promise.emit("success", true);
191+
emitter.emit("success", true);
192192
});
193-
return promise;
193+
return emitter;
194194
},
195195
"should pass `null` as first argument, if the test is expecting an error": function (e, res) {
196196
assert.strictEqual(e, null);
@@ -581,12 +581,12 @@ vows.describe("Vows with sub events").addBatch({
581581
events.EventEmitter.call(this);
582582
};
583583
require('util').inherits(MyEmitter, events.EventEmitter);
584-
584+
585585
var topic = new(MyEmitter);
586586
process.nextTick(function () {
587587
topic.emit('success', 'Legacy Does not Catch');
588588
});
589-
589+
590590
return topic;
591591
},
592592
"will return the emitter for traditional vows" : function (err, ret) {

0 commit comments

Comments
 (0)