@@ -274,20 +274,21 @@ vows.tell = function (subject, tests) {
274
274
// If it encounters a `topic` function, it waits for the returned
275
275
// promise to emit (the topic), at which point it runs the functions under it,
276
276
// passing the topic as an argument.
277
- ( function run ( ctx ) {
277
+ ( function run ( ctx , lastTopic ) {
278
278
var ctxAdded = false ;
279
279
280
- if ( 'topic' in ctx . tests ) {
281
-
280
+ topic = lastTopic = ( 'topic' in ctx . tests ) ? ctx . tests . topic
281
+ : lastTopic ;
282
+ if ( topic ) {
282
283
// Topic isn't a function, wrap it into one.
283
- if ( typeof ( ctx . tests . topic ) !== 'function' ) {
284
- ctx . tests . topic = ( function ( topic ) {
284
+ if ( typeof ( topic ) !== 'function' ) {
285
+ topic = ( function ( topic ) {
285
286
return function ( ) { return topic } ;
286
- } ) ( ctx . tests . topic ) ;
287
+ } ) ( topic ) ;
287
288
}
288
289
289
290
// Run the topic, passing the previous context topics
290
- topic = ctx . tests . topic . apply ( ctx . env , ctx . topics ) ;
291
+ topic = topic . apply ( ctx . env , ctx . topics ) ;
291
292
292
293
// If the topic doesn't return an event emitter (such as a promise),
293
294
// we create it ourselves, and emit the value on the next tick.
@@ -334,11 +335,11 @@ vows.tell = function (subject, tests) {
334
335
if ( topic ) {
335
336
topic . addListener ( "success" , function ( vow , ctx ) {
336
337
return function ( val ) {
337
- return run ( new ( Context ) ( vow , ctx , env ) ) ;
338
+ return run ( new ( Context ) ( vow , ctx , env ) , lastTopic ) ;
338
339
} ;
339
340
} ( vow , ctx ) ) ;
340
341
} else {
341
- run ( new ( Context ) ( vow , ctx , env ) ) ;
342
+ run ( new ( Context ) ( vow , ctx , env ) , lastTopic ) ;
342
343
}
343
344
}
344
345
} ) ;
0 commit comments