@@ -220,10 +220,11 @@ vows.tell = function (topic, tests) {
220
220
// functions have access to all the previous context topics in their
221
221
// arguments list.
222
222
// It is defined and invoked at the same time.
223
- // If it encouters a `setup` function, it waits for the returned
223
+ // If it encounters a `setup` function, it waits for the returned
224
224
// promise to emit (the topic), at which point it runs the functions under it,
225
225
// passing the topic as an argument.
226
226
( function run ( ctx ) {
227
+ var ctxAdded = false ;
227
228
if ( typeof ( ctx . tests [ "setup" ] ) === 'function' ) {
228
229
// Run the setup, passing the previous context topics
229
230
setup = ctx . tests . setup . apply ( this , ctx . topics ) ;
@@ -237,6 +238,13 @@ vows.tell = function (topic, tests) {
237
238
return function ( ) { emitter . emit ( "success" , val ) } ;
238
239
} ( setup ) ) ; setup = emitter ;
239
240
}
241
+
242
+ setup . addListener ( 'success' , function ( val ) {
243
+ // Once the setup fires, add the return value
244
+ // to the beginning of the topics list, so it
245
+ // becomes the first argument for the next setup.
246
+ ctx . topics . unshift ( val ) ;
247
+ } ) ;
240
248
} else { setup = null }
241
249
242
250
// Now run the tests, or sub-contexts
@@ -260,10 +268,6 @@ vows.tell = function (topic, tests) {
260
268
if ( setup ) {
261
269
setup . addListener ( "success" , function ( vow , ctx ) {
262
270
return function ( val ) {
263
- // Once the setup fires, add the return value
264
- // to the beginning of the topics list, so it
265
- // becomes the first argument for the next setup.
266
- ctx . topics . unshift ( val ) ;
267
271
return run ( new ( Context ) ( vow , ctx ) ) ;
268
272
} ;
269
273
} ( vow , ctx ) ) ;
0 commit comments