@@ -199,7 +199,7 @@ vows.options = {
199
199
// Run all vows/tests.
200
200
// It can take either a function as `tests`,
201
201
// or an object literal.
202
- vows . tell = function ( topic , tests ) {
202
+ vows . tell = function ( subject , tests ) {
203
203
this . options . Emitter . prototype . addVow = addVow ;
204
204
this . tests = tests ;
205
205
this . remaining = 0 ;
@@ -222,14 +222,14 @@ vows.tell = function (topic, tests) {
222
222
223
223
// We run the tests asynchronously, for added flexibility
224
224
process . nextTick ( function ( ) {
225
- var setup , vow , env ;
225
+ var topic , vow , env ;
226
226
227
- if ( typeof ( topic ) === 'string' && tests ) {
227
+ if ( typeof ( subject ) === 'string' && tests ) {
228
228
if ( ! vows . options . brief ) {
229
229
puts ( '\n' + stylize ( topic , 'underline' ) + '\n' ) ;
230
230
}
231
- } else if ( topic instanceof Object || topic instanceof Function ) {
232
- vows . tests = topic ;
231
+ } else if ( subject instanceof Object || subject instanceof Function ) {
232
+ vows . tests = subject ;
233
233
} else { throw "tell() takes a topic and an Object" }
234
234
235
235
start = new ( Date ) ;
@@ -257,49 +257,49 @@ vows.tell = function (topic, tests) {
257
257
} ) ( vows . tests ) ;
258
258
259
259
// The test runner, it calls itself recursively, passing the
260
- // previous context to the inner contexts. This is so the `setup `
260
+ // previous context to the inner contexts. This is so the `topic `
261
261
// functions have access to all the previous context topics in their
262
262
// arguments list.
263
263
// It is defined and invoked at the same time.
264
- // If it encounters a `setup ` function, it waits for the returned
264
+ // If it encounters a `topic ` function, it waits for the returned
265
265
// promise to emit (the topic), at which point it runs the functions under it,
266
266
// passing the topic as an argument.
267
267
( function run ( ctx ) {
268
268
var ctxAdded = false ;
269
269
270
- if ( 'setup ' in ctx . tests ) {
270
+ if ( 'topic ' in ctx . tests ) {
271
271
272
- // Setup isn't a function, wrap it into one.
273
- if ( typeof ( ctx . tests . setup ) !== 'function' ) {
274
- ctx . tests . setup = ( function ( topic ) {
272
+ // Topic isn't a function, wrap it into one.
273
+ if ( typeof ( ctx . tests . topic ) !== 'function' ) {
274
+ ctx . tests . topic = ( function ( topic ) {
275
275
return function ( ) { return topic } ;
276
- } ) ( ctx . tests . setup ) ;
276
+ } ) ( ctx . tests . topic ) ;
277
277
}
278
278
279
- // Run the setup , passing the previous context topics
280
- setup = ctx . tests . setup . apply ( ctx . env , ctx . topics ) ;
279
+ // Run the topic , passing the previous context topics
280
+ topic = ctx . tests . topic . apply ( ctx . env , ctx . topics ) ;
281
281
282
- // If the setup doesn't return an event emitter (such as a promise),
282
+ // If the topic doesn't return an event emitter (such as a promise),
283
283
// we create it ourselves, and emit the value on the next tick.
284
- if ( ! ( setup instanceof vows . options . Emitter ) ) {
284
+ if ( ! ( topic instanceof vows . options . Emitter ) ) {
285
285
var emitter = new ( vows . options . Emitter ) ;
286
286
287
287
process . nextTick ( function ( val ) {
288
288
return function ( ) { emitter . emit ( "success" , val ) } ;
289
- } ( setup ) ) ; setup = emitter ;
289
+ } ( topic ) ) ; topic = emitter ;
290
290
}
291
291
292
- setup . addListener ( 'success' , function ( val ) {
293
- // Once the setup fires, add the return value
292
+ topic . addListener ( 'success' , function ( val ) {
293
+ // Once the topic fires, add the return value
294
294
// to the beginning of the topics list, so it
295
- // becomes the first argument for the next setup .
295
+ // becomes the first argument for the next topic .
296
296
ctx . topics . unshift ( val ) ;
297
297
} ) ;
298
- } else { setup = null }
298
+ } else { topic = null }
299
299
300
300
// Now run the tests, or sub-contexts
301
301
Object . keys ( ctx . tests ) . filter ( function ( k ) {
302
- return ctx . tests [ k ] && k !== 'setup ' ;
302
+ return ctx . tests [ k ] && k !== 'topic ' ;
303
303
} ) . forEach ( function ( item ) {
304
304
// Holds the current test or context
305
305
vow = Object . create ( {
@@ -311,18 +311,18 @@ vows.tell = function (topic, tests) {
311
311
env = Object . create ( ctx . env ) ;
312
312
313
313
// If we encounter a function, add it to the callbacks
314
- // of the `setup ` function, so it'll get called once the
315
- // setup fires.
314
+ // of the `topic ` function, so it'll get called once the
315
+ // topic fires.
316
316
// If we encounter an object literal, we recurse, sending it
317
317
// our current context.
318
318
if ( typeof ( vow . callback ) === 'function' ) {
319
- setup . addVow ( vow ) ;
319
+ topic . addVow ( vow ) ;
320
320
} else if ( typeof ( vow . callback ) === 'object' && ! Array . isArray ( vow . callback ) ) {
321
321
// If there's a setup stage, we have to wait for it to fire,
322
322
// before calling the inner context. Else, just run the inner context
323
323
// synchronously.
324
- if ( setup ) {
325
- setup . addListener ( "success" , function ( vow , ctx ) {
324
+ if ( topic ) {
325
+ topic . addListener ( "success" , function ( vow , ctx ) {
326
326
return function ( val ) {
327
327
return run ( new ( Context ) ( vow , ctx , env ) ) ;
328
328
} ;
0 commit comments