Created
October 28, 2010 19:16
-
-
Save indexzero/652118 to your computer and use it in GitHub Desktop.
vows-journey-web-service.js
This file contains hidden or 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 sample.js --spec | |
The 'sys' module is now called 'util'. It should have a similar interface. | |
♢ some/sample/test | |
When using my test server any http request | |
✓ should respond with hello world | |
When the tests are complete | |
✓ stop the test server | |
✓ OK » 2 honored (0.005s) |
This file contains hidden or 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
var vows = require('vows'), | |
assert = require('assert'), | |
http = require('http'), | |
request = require('request'); // npm install request | |
var server = http.createServer(function (req, res) { | |
res.writeHead(200, {'Content-Type': 'text/plain'}); | |
res.write('hello world'); | |
res.end(); | |
}); | |
server.listen(8080); | |
vows.describe('some/sample/test').addBatch({ | |
"When using my test server": { | |
"any http request": { | |
topic: function () { | |
request({ uri: 'http://127.0.0.1:8080' }, this.callback); | |
}, | |
"should respond with hello world": function (err, res, body) { | |
assert.equal(body, 'hello world'); | |
assert.equal(res.statusCode, 200); | |
} | |
} | |
} | |
}).addBatch({ | |
"When the tests are complete": { | |
"stop the test server": function () { | |
server.close(); | |
} | |
} | |
}).export(module); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment