Created
August 13, 2011 15:43
-
-
Save ToQoz/1143969 to your computer and use it in GitHub Desktop.
vows intro written in coffeescript
This file contains 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
# coffee version of vows intro in http://vowsjs.org/ | |
exports.Strawberry = () -> | |
this.color = '#ff0000' | |
exports.Strawberry.prototype = | |
isTasty: () -> true | |
exports.Banana = ()-> | |
this.color = '#fff333' | |
exports.Banana.prototype = | |
peel: (callback) -> | |
process.nextTick () -> | |
callback null, new exports.PeeledBanana | |
peelSync:() -> new exports.PeeledBanana | |
exports.PeeledBanana = ()-> |
This file contains 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
vows = require 'vows' | |
assert = require 'assert' | |
theGoodThings = require './the-good-things' | |
Strawberry = theGoodThings.Strawberry | |
Banana = theGoodThings.Banana | |
PeeledBanana = theGoodThings.PeeledBanana | |
vows.describe('The Good Things').addBatch | |
'A strawberry': | |
topic: new(Strawberry), | |
'is red': (strawberry)-> | |
assert.equal strawberry.color, '#ff0000' | |
'and tasty': (strawberry)-> | |
assert.isTrue strawberry.isTasty() | |
'A banana': | |
topic: new(Banana), | |
'when peeled *synchronously*': | |
topic: (banana)-> | |
return banana.peelSync() | |
'returns a `PeeledBanana`': (result)-> | |
assert.instanceOf result, PeeledBanana | |
'when peeled *asynchronously*': | |
topic: (banana)-> | |
banana.peel this.callback | |
'results in a `PeeledBanana`': (err, result)-> | |
assert.instanceOf result, PeeledBanana | |
.export(module) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment