cloudhead/vows — pull request #162 by seebees (2011-11-28 03:49:06+00:00)
Title: Synchronous Vows

Array literal and 'next' are syntactic sugar for nested Context.

This should make it easy to run Synchronous vows without a nesting headache.

Detail below, Fixes #53

This is not ready to merge, but I'm off my plane and would like someone to comment before going farther.
Also, the addition of synchronous tests almost make we want to copy the vows-tests.js and re-write every case. Hopefully I don't need to be that crazy.

context.js
Context is now an EventEmitter
Each Context knows it's children and parent
Each Context also receive an array of vows.
addVow added to Context.prototype to push vow onto Context.
nextTopics added to Context.prototype to handle new 'next' declaration to use in synchronous Context
tryEnd added to Context.prototype to emit event when this Context (and all it's children) are 'complete'

vows.js
vow.binding.context.addVow, need to add the vow to the Context
vows.tryEnd(batch, vow), need to pass the vow to tryEnd so we can call Context.tryEnd(vow)

suite.js
added 'next' to all Object.keys(tests).filter
you can not have both a topic and a next declaration
the topic when running all vows is: topic || next. Need a bit of logic magic to make this work
use ctx.nextTopics() to get the right topics to pass to the topic function
add a uuid to the vow object. (need a better implementation then Math.random())
if Array.isArray(ctx.tests) we may need to waitForSibling (this is that for the sake of which we did all this)
tryEnd is defined here, added a vow param, and if we have one, tryEnd the Context