Skip to content

Instantly share code, notes, and snippets.

@pietern
Forked from tj/example.spec.js
Created April 8, 2010 18:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pietern/360366 to your computer and use it in GitHub Desktop.
Save pietern/360366 to your computer and use it in GitHub Desktop.
// this scopes the contents to the current spec
// doesn't matter if callback is fired way later than timeout
it "should work"
var contents
fs.readFile('foo', function(err, c){
contents = c
})
wait(-{
contents.should.eql 'bar'
}, 50)
end
// the function "callback" (or "async" or whatever) adds a wait
// function to the wait queue that checks if the function is
// called before timeout. also, store the currentSpec to check
// if the scope is still correct if the function fires way too late
it "should work"
fs.readFile('foo', callback(function(err, contents){
contents.should.eql 'bar'
}))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment