1
0
Fork 0
mirror of https://github.com/kbparagua/paloma synced 2023-03-27 23:21:17 -04:00

Spec for ControllerBuilder

This commit is contained in:
kbparagua 2013-10-12 17:59:22 +08:00
parent 0b15b34268
commit 55b98fed77
4 changed files with 64 additions and 1 deletions

View file

@ -0,0 +1,48 @@
describe('Paloma.ControllerFactory', function(){
var router = new Paloma.Router({namespace: '/', action: '#'});
describe('#make(name)', function(){
var factory = new Paloma.ControllerFactory(router),
Controller;
beforeEach(function(){
Controller = factory.make('Resource');
});
it('returns a new Controller constructor', function(){
expect(typeof Controller).toEqual('function');
});
it('saves the Controller constructor', function(){
expect(factory.get('Resource')).toEqual(Controller);
});
});
describe('#get(name)', function(){
var factory = new Paloma.ControllerFactory(router),
Controller = factory.make('Foo');
describe('when controller exists', function(){
it('returns the controller', function(){
expect(factory.get('Foo')).toEqual(Controller);
});
});
describe('when controller does not exist', function(){
it('returns null', function(){
expect(factory.get('WhatTheFuck')).toBeNull();
});
});
});
});

View file

@ -0,0 +1,10 @@
(function(Paloma){
var Controller = function(params){
this.params = params;
};
Paloma.Controller = Controller;
})(window.Paloma);

View file

@ -38,7 +38,11 @@
var createConstructor = function(){
var constructor = function(params){ this.params = params; };
var constructor = function(params){ this.params = params; }
$.extend(constructor, Paloma.Controller);
$.extend(constructor.prototype, Paloma.Controller.prototype);
return constructor;
};

View file

@ -1,4 +1,5 @@
//= require ./init.js
//= require ./router.js
//= require ./controller.js
//= require ./controller_builder.js
//= require ./paloma.js