Celluloid is a concurrent object oriented programming framework for Ruby which lets you build multithreaded programs out of concurrent objects just as easily as you build sequential programs out of regular objects
vows= require('vows')fs= require('fs')assert= require('assert')vows.describe('Division by zero').addBatch'when dividing a number by zero':#topic is function and returns a valuetopic: ->42/0# the topic value is used as an argument'we get Infinity':(topic) ->assert.equaltopic,Infinity'but when dividing zero by zero':#topic is only run once. Hence the value is different from# example value abovetopic: ->0/0'we get a value which':'is not a number':(topic) ->assert.isNaNtopic#topic has a scope. we use the same 0 / 0 value here.'is not equal to itself':(topic) ->assert.notEqualtopic,topic
Writing asynchronous tests
1234567891011121314151617181920
.addBatch'A introduction file':topic: -># this.callback function is available inside all topics# When this.callback is called, it passes on the arguments# it received to the test functions, one by one, as if # the values were returned by the topic function itself.# this allows us to decouple callback from they async function call# topics which do not return anything must take use of 'this.callback'fs.stat'000_intro.coffee',this.callback'can be accessed':(err, stat) -># we have no errassert.isNullerr# we have a stat objectassert.isObjectstat'is not empty':(err, stat) -># the file size is > 0assert.isNotZerostat.size.run()