Skip to content

Commit

Permalink
little details
Browse files Browse the repository at this point in the history
  • Loading branch information
gaarf committed Feb 16, 2012
1 parent 235a3f8 commit a4901d7
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 6 deletions.
7 changes: 5 additions & 2 deletions Makefile
@@ -1,10 +1,13 @@
mongod:
mongod run --config /usr/local/etc/mongod.conf

test:
mocha --reporter list
mocha --reporter spec

server:
node boot.js

routes:
node console.js routes

.PHONY: test routes
.PHONY: mongod test server routes
4 changes: 3 additions & 1 deletion boot.js
Expand Up @@ -63,7 +63,7 @@ _.forEach(fs.readdirSync('./models'), function(file){
if(file.match(/\.js$/)) {
var s = require('./models/' + file);
if(s.name) {
schemas[s.name] = s.get(mongoose)
schemas[s.name] = s.get(mongoose);
}
}
});
Expand Down Expand Up @@ -133,6 +133,8 @@ _.forEach(schemas, function(schema, name){
app.use(express.csrf());

app.use(mongooseAuth.middleware());

app.use(app.router); // cf https://github.com/bnoguchi/mongoose-auth/issues/52
});

app.configure('development', function(){
Expand Down
5 changes: 5 additions & 0 deletions controllers/index.controller.js
Expand Up @@ -14,6 +14,11 @@ module.exports.setRoutes = function(app, kit) {
res.json(req.user);
});


app.get('/bad', function(req, res){
omgWtfBbq(); // undefined
});

return app;
}

23 changes: 22 additions & 1 deletion test/another.test.js
Expand Up @@ -11,7 +11,7 @@ describe('With server listening', function(){

it('responds ok', function(done){
helper.localRequest('GET /favicon.ico', function(res) {
res.statusCode.should.equal(200);
res.should.have.status(200);
done();
})
})
Expand All @@ -20,3 +20,24 @@ describe('With server listening', function(){

})

describe('kit', function(){

it('contains utilities', function(){
boot.kit.model.should.be.a('object').and.have.property('User');
boot.kit.middleware.should.be.a('object');
boot.kit.sessionStorage.should.be.a('object');
boot.kit.dateformat.should.be.a('function');
boot.kit.parallelize.should.be.a('function');
boot.kit.secrets.get.should.be.a('function');
})

it('does not contain bbq', function(){
boot.kit.should.be.a('object');
boot.kit.should.not.have.property('req')
boot.kit.should.not.have.property('res')
boot.kit.should.not.have.property('app')
boot.kit.should.not.have.property('bbq')
})


})
16 changes: 14 additions & 2 deletions test/default.test.js
Expand Up @@ -11,19 +11,31 @@ describe('With server listening', function(){

it('responds ok', function(done){
helper.localRequest('GET /', function(res) {
res.statusCode.should.equal(200);
res.should.have.status(200);
res.body.should.include('is running fine');
done();
})
})

})

// describe('page that causes an error', function(){
//
// it('shows express error page', function(){
// helper.localRequest('GET /bad', function(res) {
// res.should.have.status(500);
// res.body.should.include('omgWtfBbq is not defined');
// done();
// })
// })
//
// })

describe('page that does not exist', function(){

it('is not found', function(){
helper.localRequest('POST /four.ofour', function(res) {
res.statusCode.should.equal(404);
res.should.have.status(404);
done();
})
})
Expand Down

0 comments on commit a4901d7

Please sign in to comment.