Skip to content

Instantly share code, notes, and snippets.

@GraemeF
Created November 28, 2011 17:43
Show Gist options
  • Save GraemeF/1401254 to your computer and use it in GitHub Desktop.
Save GraemeF/1401254 to your computer and use it in GitHub Desktop.
vows-bdd
{Feature} = require "vows-bdd"
vows = require 'vows'
assert = require 'assert'
Feature("Share stuff between steps", module)
.scenario("Set properties on given and when")
.given "A is set", ->
@A = "A"
@callback()
.when "I set B", ->
@B = "B"
@callback()
.then "A should still be set", ->
assert.equal @A, "A"
.and "B should still be set", ->
assert.equal @B, "B"
.complete()
.finish(module)
@jmreidy
Copy link

jmreidy commented Nov 28, 2011

Check out my fork. The reason why process.nextTick wasn't working was that the vows context wasn't being applied properly. There's some magic under the vows covers; it's continuously using fn.apply to keep this pointing at the vows context properly, and calling process.nextTick @callback directly causes a problem there. You can verify the different behaviors by dropping console.log this in the then blocks

@GraemeF
Copy link
Author

GraemeF commented Nov 28, 2011

That's great - so basically "don't do that" :)

Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment