Created
May 31, 2012 23:41
-
-
Save denzuko/2847236 to your computer and use it in GitHub Desktop.
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
| (function() { | |
| describe('Application', function() { | |
| it('should exists', function() { | |
| var app = new Application(); | |
| app.should.be.an.instanceof(Application); | |
| }); | |
| }); | |
| }).call(this); | |
| function Application(template_id){ | |
| var source = $(template_id); | |
| this.template = Handlebars.compile(source.html()); | |
| } | |
| Application.prototype.render = function(params){ | |
| return this.template(params); | |
| }; |
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
| <script id="test-template" type="text/x-handlebars-template"> | |
| <p></p> | |
| </script> |
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
| { | |
| "engines": { | |
| "node": "0.6.13", | |
| "npm": "1.1.15"}, | |
| "dependencies": { | |
| "express": "2.2.0", | |
| "should": "0.6.5", | |
| "mocha" | |
| "main": app/server.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
| var express = require('express'), | |
| app = express.createServer(); | |
| app.configure(function(){ | |
| app.set('views', __dirname + '/views'); | |
| app.set('views'); | |
| // => "/absolute/path/to/views" | |
| app.enable('some feature'); | |
| // same as app.set('some feature', true); | |
| app.disable('some feature'); | |
| // same as app.set('some feature', false); | |
| app.enabled('some feature') | |
| // => false | |
| }); | |
| app.get('/', function(req, res){ | |
| // res.send('hello world'); | |
| }); | |
| app.listen(3000); |
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
| it('should render handlebars template', function(){ | |
| var app = new Application("#test-template"); | |
| app.render({name: "kuba"}).should.equal("<p>kuba</p>"); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment