mirror of
https://github.com/kbparagua/paloma
synced 2023-03-27 23:21:17 -04:00
Spec for ControllerBuilder
This commit is contained in:
parent
0b15b34268
commit
55b98fed77
4 changed files with 64 additions and 1 deletions
48
test_app/spec/javascripts/controller_builder_spec.js
Normal file
48
test_app/spec/javascripts/controller_builder_spec.js
Normal 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();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
10
vendor/assets/javascripts/paloma/controller.js
vendored
Normal file
10
vendor/assets/javascripts/paloma/controller.js
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
(function(Paloma){
|
||||
|
||||
var Controller = function(params){
|
||||
this.params = params;
|
||||
};
|
||||
|
||||
|
||||
Paloma.Controller = Controller;
|
||||
|
||||
})(window.Paloma);
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
1
vendor/assets/javascripts/paloma/index.js
vendored
1
vendor/assets/javascripts/paloma/index.js
vendored
|
@ -1,4 +1,5 @@
|
|||
//= require ./init.js
|
||||
//= require ./router.js
|
||||
//= require ./controller.js
|
||||
//= require ./controller_builder.js
|
||||
//= require ./paloma.js
|
Loading…
Reference in a new issue