Skip to content

Instantly share code, notes, and snippets.

@mdb
Created July 20, 2012 12:58
Show Gist options
  • Save mdb/3150605 to your computer and use it in GitHub Desktop.
Save mdb/3150605 to your computer and use it in GitHub Desktop.
var autheremin = require('autheremin');
var http = require('http');
var port = process.argv[2] || 4824;
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}).listen(port, '127.0.0.1');
console.log('Server running at http://127.0.0.1:' + port);
var assert = require("assert");
var request = require("request");
describe('auther', function () {
var auther = require("../auther");
it('exists', function () {
it('should not be null', function () {
assert.notEqual(auther, null);
});
it('should not be undefined', function () {
assert.notEqual(auther, undefined);
});
});
it('starts a server that listens on port 4824 by default', function () {
request('http://localhost:4824', function(err, resp, body) {
assert(resp.statusCode === 200);
});
});
//when we send a put request to localhost/some_username with a request body contaning a password and an api key, author will return 200 ok
it('returns 200 when we send a PUT request to localhost/someUser', function () {
// start up auther server
// form the request
// send the request
// get the response
// response body should be 200
});
});
$ mocha tests/auther.js
fs.js:400
return binding.readdir(pathModule._makeLong(path));
^
Error: ENOTDIR, not a directory 'tests/auther.js'
at Object.readdirSync (fs.js:400:18)
at lookupFiles (/usr/local/lib/node_modules/mocha/bin/_mocha:396:6)
at /usr/local/lib/node_modules/mocha/bin/_mocha:241:24
at Array.forEach (native)
at Object.<anonymous> (/usr/local/lib/node_modules/mocha/bin/_mocha:240:6)
at Module._compile (module.js:446:26)
at Object..js (module.js:464:10)
at Module.load (module.js:353:31)
at Function._load (module.js:311:12)
at Array.0 (module.js:484:10)
at EventEmitter._tickCallback (node.js:190:38)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment