Skip to content

Commit

Permalink
[fix doc] Remove all mentions of the word "promise", vows is based on…
Browse files Browse the repository at this point in the history
… the EventEmitter.
  • Loading branch information
indexzero committed Nov 22, 2014
1 parent a8314b8 commit 73872a8
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 30 deletions.
4 changes: 2 additions & 2 deletions lib/vows.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function addVow(vow) {
if (vow.callback.length >= 2 || !batch.suite.options.error) {
runTest(arguments, this.ctx);
} else {
output('errored', { type: 'promise', error: err.stack ||
output('errored', { type: 'emitter', error: err.stack ||
err.message || JSON.stringify(err) });
}
vows.tryEnd(batch);
Expand Down Expand Up @@ -162,7 +162,7 @@ function addVow(vow) {
};

//
// On exit, check that all promises have been fired.
// On exit, check that all emitters have been fired.
// If not, report an error message.
//
process.on('exit', function () {
Expand Down
2 changes: 1 addition & 1 deletion lib/vows/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ this.vowText = function (event) {
if (event.status === 'broken') {
buffer.push(' » ' + event.exception);
} else if (event.status === 'errored') {
if (event.exception.type === 'promise') {
if (event.exception.type === 'emitter') {
buffer.push(' » ' + this.stylize("An unexpected error was caught: " +
this.stylize(event.exception.error, 'bold'), 'red'));
} else {
Expand Down
12 changes: 6 additions & 6 deletions lib/vows/suite.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ this.Suite.prototype = new(function () {
if ('topic' in tests) {
throw new(Error)("missing top-level context.");
}
// Count the number of vows/promises expected to fire,
// Count the number of vows/emitters expected to fire,
// so we know when the tests are over.
// We match the keys against `matcher`, to decide
// whether or not they should be included in the test.
Expand Down Expand Up @@ -105,7 +105,7 @@ this.Suite.prototype = new(function () {
this.runBatch = function (batch) {
var topic,
tests = batch.tests,
promise = batch.promise = new(events.EventEmitter);
emitter = batch.emitter = new(events.EventEmitter);

var that = this;

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

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

this.report = function () {
Expand Down Expand Up @@ -395,7 +395,7 @@ this.tryEnd = function (batch) {
function finish() {
batch.status = 'end';
batch.suite.report(['end']);
batch.promise.emit('end', batch.honored, batch.broken, batch.errored, batch.pending);
batch.emitter.emit('end', batch.honored, batch.broken, batch.errored, batch.pending);
}
}
};
42 changes: 21 additions & 21 deletions test/vows-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ var api = vows.prepare({
version: function () { return '1.0' }
}, ['get']);

var promiser = function (val) {
var emitNextTick = function (val) {
return function () {
var promise = new(events.EventEmitter);
process.nextTick(function () { promise.emit('success', val) });
return promise;
var emitter = new(events.EventEmitter);
process.nextTick(function () { emitter.emit('success', val) });
return emitter;
}
};

vows.describe("Vows").addBatch({
"A context": {
topic: promiser("hello world"),
topic: emitNextTick("hello world"),

"with a nested context": {
topic: function (parent) {
this.state = 42;
return promiser(parent)();
return emitNextTick(parent)();
},
"has access to the environment": function () {
assert.equal(this.state, 42);
Expand All @@ -47,24 +47,24 @@ vows.describe("Vows").addBatch({
}
},
"A nested context": {
topic: promiser(1),
topic: emitNextTick(1),

".": {
topic: function (a) { return promiser(2)() },
topic: function (a) { return emitNextTick(2)() },

".": {
topic: function (b, a) { return promiser(3)() },
topic: function (b, a) { return emitNextTick(3)() },

".": {
topic: function (c, b, a) { return promiser([4, c, b, a])() },
topic: function (c, b, a) { return emitNextTick([4, c, b, a])() },

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

"from": {
topic: function (c, b, a) { return promiser([4, c, b, a])() },
topic: function (c, b, a) { return emitNextTick([4, c, b, a])() },

"the parent topics": function(topics) {
assert.equal(topics.join(), [4, 3, 2, 1].join());
Expand Down Expand Up @@ -121,9 +121,9 @@ vows.describe("Vows").addBatch({
}
}
},
"A non-promise return value": {
"A non-EventEmitter return value": {
topic: function () { return 1 },
"should be converted to a promise": function (val) {
"should be converted to a vow": function (val) {
assert.equal(val, 1);
}
},
Expand Down Expand Up @@ -173,11 +173,11 @@ vows.describe("Vows").addBatch({
},
"A topic emitting an error": {
topic: function () {
var promise = new(events.EventEmitter);
var emitter = new(events.EventEmitter);
process.nextTick(function () {
promise.emit("error", 404);
emitter.emit("error", 404);
});
return promise;
return emitter;
},
"shouldn't raise an exception if the test expects it": function (e, res) {
assert.equal(e, 404);
Expand All @@ -186,11 +186,11 @@ vows.describe("Vows").addBatch({
},
"A topic not emitting an error": {
topic: function () {
var promise = new(events.EventEmitter);
var emitter = new(events.EventEmitter);
process.nextTick(function () {
promise.emit("success", true);
emitter.emit("success", true);
});
return promise;
return emitter;
},
"should pass `null` as first argument, if the test is expecting an error": function (e, res) {
assert.strictEqual(e, null);
Expand Down Expand Up @@ -581,12 +581,12 @@ vows.describe("Vows with sub events").addBatch({
events.EventEmitter.call(this);
};
require('util').inherits(MyEmitter, events.EventEmitter);

var topic = new(MyEmitter);
process.nextTick(function () {
topic.emit('success', 'Legacy Does not Catch');
});

return topic;
},
"will return the emitter for traditional vows" : function (err, ret) {
Expand Down

0 comments on commit 73872a8

Please sign in to comment.