Skip to content

Commit

Permalink
Async topic is passed to vows with topic-less subcontext
Browse files Browse the repository at this point in the history
Fixes #53
  • Loading branch information
seebees committed Nov 26, 2011
1 parent 82d5541 commit 9853e64
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/vows/suite.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,13 @@ this.Suite.prototype = new(function () {
};
}(topic));
}
topic = ctx.emitter;
// if I have a callback, push the new topic back up to
// lastTopic
if (ctx._callback) {
lastTopic = topic = ctx.emitter;
} else {
topic = ctx.emitter;
}
}
}

Expand Down
28 changes: 28 additions & 0 deletions test/vows-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -484,3 +484,31 @@ vows.describe("Vows with asynchonous teardowns").addBatch({
}
}
}).export(module);

vows.describe('Async topic is passed to vows with topic-less subcontext').addBatch({
'Async 42': {
topic: function () {
var callback = this.callback;
process.nextTick(function () {
callback(null, 42);
});
},
'equals 42': function (topic) {
assert.equal(topic, 42);
},
'has the property that': {
'it is equal to 42': function (topic) {
// <-- This vow fails, topic is undefined!?
assert.equal(topic, 42);
}
},
'plus 1': {
topic: function (parentTopic) {
return parentTopic + 1;
},
'equals 43': function (topic) {
assert.equal(topic, 43);
}
}
}
})['export'](module);

0 comments on commit 9853e64

Please sign in to comment.