Permalink
Browse files

use should-as-global & do not throw on getting a value of undefined box

  • Loading branch information...
eldargab committed Sep 3, 2012
1 parent 50b898e commit 2057668e2220ea0e6e6c12dc0ecf672a08de6f21
Showing with 8 additions and 9 deletions.
  1. +2 −1 lib/app.js
  2. +1 −0 package.json
  3. +4 −7 test/app.js
  4. +1 −1 test/mocha.opts
View
@@ -50,7 +50,8 @@ App.prototype._box = function (p) {
App.prototype.get = function (path) {
var p = this._resolve(path)
var box = this._box(p)
var box = this['_box_' + p] || this['_box_proto_' + p]
if (!box) return
if (!box.isReady) throw new Error('Box ' + p + 'is not yet evaluated')
return box.val
}
View
@@ -8,6 +8,7 @@
"repository": "https://github.com/eldargab/the-box.git",
"devDependencies": {
"should": "*",
"should-as-global": "*",
"mocha": "*",
"sinon": "*"
},
View
@@ -1,5 +1,4 @@
var sinon = require('sinon')
var should = require('should')
var App = require('../lib/app')
describe('App', function () {
@@ -85,9 +84,9 @@ describe('App', function () {
xc = done
}).eval('a', cb)
should.not.exist(xxb)
assert.not.exist(xxb)
xc()
should.not.exist(a)
assert.not.exist(a)
xxb()
a()
cb.hasValue()
@@ -110,10 +109,8 @@ describe('App', function () {
app.get('bar').should.equal('bar')
})
it('Throws if box is undefined', function () {
;(function () {
app.get('undefined')
}).should.throw()
it('Returns undefined if box is not defined', function () {
assert.not.exist(app.get('undefined'))
})
it('Throws if box is not evaluated', function () {
View
@@ -1 +1 @@
--require should
--require should-as-global

0 comments on commit 2057668

Please sign in to comment.