Skip to content

Instantly share code, notes, and snippets.

@brettstimmerman
Created September 19, 2010 07:07
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 brettstimmerman/586509 to your computer and use it in GitHub Desktop.
Save brettstimmerman/586509 to your computer and use it in GitHub Desktop.
/*
This Vows test suite produces the following spec output with vows 0.5.1 and
node 0.2.1.
♢ Emitter
A NonEmitter does not inherit from EventEmitter
✓ and can be tested
✗ Errored » Emitter: An Emitter inherits from EventEmitter ∙ not fired!
✗ Errored » 1 honored ∙ 1 errored ∙ 1 dropped
*/
var assert = require('assert'),
events = require('events'),
vows = require('vows');
function Emitter () {}
Emitter.prototype = new events.EventEmitter();
function NonEmitter () {}
vows.describe('Inheriting from EventEmitter').addBatch({
'An Emitter': {
'inherits from EventEmitter': {
topic: function () {
return new Emitter();
},
'but cannot be tested': function (topic) {
// this will never run
assert.instanceOf(topic, Emitter);
}
}
},
'A NonEmitter': {
'does not inherit from EventEmitter': {
topic: function () {
return new NonEmitter();
},
'and can be tested': function (topic) {
assert.instanceOf(topic, NonEmitter);
}
}
}
}).export(module);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment