From 7a32865ff63634074dc4c9dc82a8a4eae6a61740 Mon Sep 17 00:00:00 2001 From: micra_000 Date: Wed, 3 Dec 2014 16:41:57 -0500 Subject: [PATCH 01/12] allow the wiring of falsy values (+ test) --- backbone.geppetto.js | 2 +- specs/src/geppetto-specs.js | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/backbone.geppetto.js b/backbone.geppetto.js index 17d26cc..1595907 100755 --- a/backbone.geppetto.js +++ b/backbone.geppetto.js @@ -145,7 +145,7 @@ if (this._mappings.hasOwnProperty(key)) { var config = this._mappings[key]; if (!overrideRules && config.type === TYPES.SINGLETON) { - if (!config.object) { + if (!config.object && config.clazz) { config.object = this._createAndSetupInstance(config); } output = config.object; diff --git a/specs/src/geppetto-specs.js b/specs/src/geppetto-specs.js index 5d80853..fc7d88a 100755 --- a/specs/src/geppetto-specs.js +++ b/specs/src/geppetto-specs.js @@ -452,6 +452,26 @@ define([ }); + describe("when wiring a value", function(){ + var context; + var spy; + beforeEach(function() { + context = new Geppetto.Context(); + }); + + spy = sinon.spy(function() { + context.wireValue('test_zero', 0); + context.wireValue('test_false', false); + context.wireValue('test_null', null); + context.wireValue('test_empty_string', ''); + }); + + it("should accept falsy values", function() { + spy.should.not.have.thrown() + }); + + }) + describe("when triggering commands", function() { var context; var CommandClass; From aa2a7fd19b0b9f245faf40db9fabad366499dd4f Mon Sep 17 00:00:00 2001 From: mmikeyy Date: Wed, 3 Dec 2014 17:17:30 -0500 Subject: [PATCH 02/12] Update geppetto-specs.js --- specs/src/geppetto-specs.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specs/src/geppetto-specs.js b/specs/src/geppetto-specs.js index fc7d88a..a92a7d2 100755 --- a/specs/src/geppetto-specs.js +++ b/specs/src/geppetto-specs.js @@ -467,7 +467,7 @@ define([ }); it("should accept falsy values", function() { - spy.should.not.have.thrown() + spy().should.not.throw() }); }) From 91288aac086dec11b231add0e92eb5a7a41a285a Mon Sep 17 00:00:00 2001 From: mmikeyy Date: Wed, 3 Dec 2014 17:49:50 -0500 Subject: [PATCH 03/12] Update geppetto-specs.js --- specs/src/geppetto-specs.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/specs/src/geppetto-specs.js b/specs/src/geppetto-specs.js index a92a7d2..981eebc 100755 --- a/specs/src/geppetto-specs.js +++ b/specs/src/geppetto-specs.js @@ -467,7 +467,8 @@ define([ }); it("should accept falsy values", function() { - spy().should.not.throw() + spy() + expect(spy).to.have.not.thrown() }); }) From 3740ccc67e410bf42fe8ad379367062c97df8c22 Mon Sep 17 00:00:00 2001 From: mmikeyy Date: Wed, 3 Dec 2014 18:12:42 -0500 Subject: [PATCH 04/12] Update geppetto-specs.js --- specs/src/geppetto-specs.js | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/specs/src/geppetto-specs.js b/specs/src/geppetto-specs.js index 981eebc..0f8cbc8 100755 --- a/specs/src/geppetto-specs.js +++ b/specs/src/geppetto-specs.js @@ -452,26 +452,6 @@ define([ }); - describe("when wiring a value", function(){ - var context; - var spy; - beforeEach(function() { - context = new Geppetto.Context(); - }); - - spy = sinon.spy(function() { - context.wireValue('test_zero', 0); - context.wireValue('test_false', false); - context.wireValue('test_null', null); - context.wireValue('test_empty_string', ''); - }); - - it("should accept falsy values", function() { - spy() - expect(spy).to.have.not.thrown() - }); - - }) describe("when triggering commands", function() { var context; From 63eb73fc811a4c87257f31978f943221a1f467b2 Mon Sep 17 00:00:00 2001 From: mmikeyy Date: Wed, 3 Dec 2014 18:19:07 -0500 Subject: [PATCH 05/12] Update resolver-specs.js --- specs/src/resolver-specs.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/specs/src/resolver-specs.js b/specs/src/resolver-specs.js index a1f75ca..772370f 100644 --- a/specs/src/resolver-specs.js +++ b/specs/src/resolver-specs.js @@ -151,9 +151,9 @@ define([ describe("when mapping a value", function() { var key = 'a value'; var value = {}; - beforeEach(function() { + beforeEach(spy = sinon.spy(function() { context.wireValue(key, value); - }); + })); it('should be determinable', function() { expect(context.hasWiring(key)).to.be.true; }); @@ -165,6 +165,23 @@ define([ var second = context.getObject(key); expect(second).to.equal(first); }); + value = false; + it("it should accept the value 'false' as mapped value", function(){ + expect(spy).to.have.not.thrown() + }); + value = ''; + it("it should accept empty string as mapped value", function(){ + expect(spy).to.have.not.thrown() + }); + value = 0; + it("it should accept 0 as mapped value", function(){ + expect(spy).to.have.not.thrown() + }); + value = null; + it("it should accept null as mapped value", function(){ + expect(spy).to.have.not.thrown() + }); + }); describe("when mapping a class", function() { var key = 'a class'; From f7a2974353a28a7bec985ead9ea2d7a0008d3bbe Mon Sep 17 00:00:00 2001 From: mmikeyy Date: Wed, 3 Dec 2014 18:33:20 -0500 Subject: [PATCH 06/12] Update backbone.geppetto.js --- backbone.geppetto.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backbone.geppetto.js b/backbone.geppetto.js index 1595907..17d26cc 100755 --- a/backbone.geppetto.js +++ b/backbone.geppetto.js @@ -145,7 +145,7 @@ if (this._mappings.hasOwnProperty(key)) { var config = this._mappings[key]; if (!overrideRules && config.type === TYPES.SINGLETON) { - if (!config.object && config.clazz) { + if (!config.object) { config.object = this._createAndSetupInstance(config); } output = config.object; From 445bd25999d139dff29ccb0e56a4028ad6e064ed Mon Sep 17 00:00:00 2001 From: mmikeyy Date: Wed, 3 Dec 2014 18:58:47 -0500 Subject: [PATCH 07/12] Update resolver-specs.js --- specs/src/resolver-specs.js | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/specs/src/resolver-specs.js b/specs/src/resolver-specs.js index 772370f..7d6dd61 100644 --- a/specs/src/resolver-specs.js +++ b/specs/src/resolver-specs.js @@ -151,9 +151,14 @@ define([ describe("when mapping a value", function() { var key = 'a value'; var value = {}; - beforeEach(spy = sinon.spy(function() { + + var spy = function(param) { + context.wireValue(key, param); + } + + beforeEach(function() { context.wireValue(key, value); - })); + }); it('should be determinable', function() { expect(context.hasWiring(key)).to.be.true; }); @@ -165,21 +170,25 @@ define([ var second = context.getObject(key); expect(second).to.equal(first); }); - value = false; + it("it should accept the value 'false' as mapped value", function(){ - expect(spy).to.have.not.thrown() + spy(false); + expect(spy).to.have.not.thrown(); }); - value = ''; + it("it should accept empty string as mapped value", function(){ - expect(spy).to.have.not.thrown() + spy(''); + expect(spy).to.have.not.thrown(); }); - value = 0; + it("it should accept 0 as mapped value", function(){ - expect(spy).to.have.not.thrown() + spy(0); + expect(spy).to.have.not.thrown(); }); - value = null; + it("it should accept null as mapped value", function(){ - expect(spy).to.have.not.thrown() + spy(null); + expect(spy).to.have.not.thrown(); }); }); From 00579e9a54606b2e85a593736d6124786be674d2 Mon Sep 17 00:00:00 2001 From: mmikeyy Date: Wed, 3 Dec 2014 19:04:33 -0500 Subject: [PATCH 08/12] Update resolver-specs.js --- specs/src/resolver-specs.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/specs/src/resolver-specs.js b/specs/src/resolver-specs.js index 7d6dd61..11784ce 100644 --- a/specs/src/resolver-specs.js +++ b/specs/src/resolver-specs.js @@ -152,9 +152,9 @@ define([ var key = 'a value'; var value = {}; - var spy = function(param) { + var spy = sinon.spy( function(param) { context.wireValue(key, param); - } + }); beforeEach(function() { context.wireValue(key, value); From baed876d700c913e138bce0b0b036a02697ac82c Mon Sep 17 00:00:00 2001 From: mmikeyy Date: Wed, 3 Dec 2014 19:27:47 -0500 Subject: [PATCH 09/12] Update resolver-specs.js --- specs/src/resolver-specs.js | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/specs/src/resolver-specs.js b/specs/src/resolver-specs.js index 11784ce..31c7b06 100644 --- a/specs/src/resolver-specs.js +++ b/specs/src/resolver-specs.js @@ -151,14 +151,10 @@ define([ describe("when mapping a value", function() { var key = 'a value'; var value = {}; + var spy; - var spy = sinon.spy( function(param) { - context.wireValue(key, param); - }); - - beforeEach(function() { - context.wireValue(key, value); - }); + context.wireValue(key, value); + it('should be determinable', function() { expect(context.hasWiring(key)).to.be.true; }); @@ -172,22 +168,34 @@ define([ }); it("it should accept the value 'false' as mapped value", function(){ - spy(false); + spy = sinon.spy(function() { + context.wireValue('false', false); + }); + spy(); expect(spy).to.have.not.thrown(); }); it("it should accept empty string as mapped value", function(){ - spy(''); + spy = sinon.spy(function() { + context.wireValue('empty_string', ''); + }); + spy(); expect(spy).to.have.not.thrown(); }); it("it should accept 0 as mapped value", function(){ - spy(0); + spy = sinon.spy(function() { + context.wireValue('zero', 0); + }); + spy(); expect(spy).to.have.not.thrown(); }); it("it should accept null as mapped value", function(){ - spy(null); + spy = sinon.spy(function() { + context.wireValue('null_value', null); + }); + spy(); expect(spy).to.have.not.thrown(); }); From e0d4592df143e4b06c3a7ecb4bc63e3b508604ff Mon Sep 17 00:00:00 2001 From: mmikeyy Date: Wed, 3 Dec 2014 19:39:26 -0500 Subject: [PATCH 10/12] Update resolver-specs.js --- specs/src/resolver-specs.js | 1 - 1 file changed, 1 deletion(-) diff --git a/specs/src/resolver-specs.js b/specs/src/resolver-specs.js index 31c7b06..2dbf99d 100644 --- a/specs/src/resolver-specs.js +++ b/specs/src/resolver-specs.js @@ -198,7 +198,6 @@ define([ spy(); expect(spy).to.have.not.thrown(); }); - }); describe("when mapping a class", function() { var key = 'a class'; From c0c1a9e1fb7666c20a780cc22547c985263b4c74 Mon Sep 17 00:00:00 2001 From: mmikeyy Date: Thu, 4 Dec 2014 12:30:35 -0500 Subject: [PATCH 11/12] Update resolver-specs.js --- specs/src/resolver-specs.js | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/specs/src/resolver-specs.js b/specs/src/resolver-specs.js index 2dbf99d..0599e55 100644 --- a/specs/src/resolver-specs.js +++ b/specs/src/resolver-specs.js @@ -151,9 +151,12 @@ define([ describe("when mapping a value", function() { var key = 'a value'; var value = {}; - var spy; - - context.wireValue(key, value); + var spy; + + + beforeEach(function() { + context.wireValue(key, value); + }); it('should be determinable', function() { expect(context.hasWiring(key)).to.be.true; @@ -166,38 +169,43 @@ define([ var second = context.getObject(key); expect(second).to.equal(first); }); - + it("it should accept the value 'false' as mapped value", function(){ spy = sinon.spy(function() { context.wireValue('false', false); + context.getObject('false'); }); spy(); expect(spy).to.have.not.thrown(); }); - + it("it should accept empty string as mapped value", function(){ spy = sinon.spy(function() { context.wireValue('empty_string', ''); + context.getObject('empty_string'); }); spy(); expect(spy).to.have.not.thrown(); }); - + it("it should accept 0 as mapped value", function(){ spy = sinon.spy(function() { context.wireValue('zero', 0); + context.getObject('zero'); }); spy(); expect(spy).to.have.not.thrown(); }); - + it("it should accept null as mapped value", function(){ spy = sinon.spy(function() { context.wireValue('null_value', null); + context.getObject('null_value'); }); spy(); expect(spy).to.have.not.thrown(); }); + }); describe("when mapping a class", function() { var key = 'a class'; From b19abfe05069c1d98382d38361b27d27dadebe56 Mon Sep 17 00:00:00 2001 From: mmikeyy Date: Thu, 4 Dec 2014 12:31:33 -0500 Subject: [PATCH 12/12] Update backbone.geppetto.js --- backbone.geppetto.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backbone.geppetto.js b/backbone.geppetto.js index 17d26cc..1595907 100755 --- a/backbone.geppetto.js +++ b/backbone.geppetto.js @@ -145,7 +145,7 @@ if (this._mappings.hasOwnProperty(key)) { var config = this._mappings[key]; if (!overrideRules && config.type === TYPES.SINGLETON) { - if (!config.object) { + if (!config.object && config.clazz) { config.object = this._createAndSetupInstance(config); } output = config.object;