-
-
Save pietern/360366 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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