Skip to content

Instantly share code, notes, and snippets.

@dakatsuka
Created September 18, 2011 10:59
Show Gist options
  • Save dakatsuka/1224981 to your computer and use it in GitHub Desktop.
Save dakatsuka/1224981 to your computer and use it in GitHub Desktop.
Vowsでイベントを捕捉する
vows = require('vows')
assert = require('assert')
events = require('events')
Hoge = require('hoge')
vows
.describe('Hoge')
.addBatch
'when using foo method':
topic: ->
promise = new events.EventEmitter()
hoge = new Hoge()
setTimeout ->
hoge.foo("bar")
, 100
hoge.on 'foo', (connection) ->
promise.emit 'success', connection
return promise
'foo event should be fired': (topic) ->
assert.equal topic, 'bar'
.export module
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment