Skip to content

Commit

Permalink
allow access to Context object, from tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudhead committed May 2, 2010
1 parent 1348def commit b78539e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/vows.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ vows.tell = function (topic, tests) {
var ctxAdded = false;
if (typeof(ctx.tests["setup"]) === 'function') {
// Run the setup, passing the previous context topics
setup = ctx.tests.setup.apply(this, ctx.topics);
setup = ctx.tests.setup.apply(ctx, ctx.topics);

// If the setup doesn't return an event emitter (such as a promise),
// we create it ourselves, and emit the value on the next tick.
Expand Down
10 changes: 10 additions & 0 deletions test/vows-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,20 @@ return vows.tell("Vows", {
},
"with a nested context": {
setup: function (parent) {
this.state = 42;
return promiser(parent)();
},
"testing equality": function (it) {
assert.equal(it, "hello world");
},
"a sub context": {
setup: function () {
return this.state;
},
"has access to the parent context object": function (r) {
assert.equal(r, 42);
assert.equal(this.state, 42);
}
}
}
},
Expand Down

0 comments on commit b78539e

Please sign in to comment.