Skip to content

Instantly share code, notes, and snippets.

@ToQoz
Created August 13, 2011 15:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ToQoz/1143969 to your computer and use it in GitHub Desktop.
Save ToQoz/1143969 to your computer and use it in GitHub Desktop.
vows intro written in coffeescript
# 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 = ()->
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