Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

  • Loading branch information...
commit 2057668e2220ea0e6e6c12dc0ecf672a08de6f21 1 parent 50b898e
Eldar Gabdullin authored
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
3  lib/app.js
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
}
1  package.json
View
@@ -8,6 +8,7 @@
"repository": "https://github.com/eldargab/the-box.git",
"devDependencies": {
"should": "*",
+ "should-as-global": "*",
"mocha": "*",
"sinon": "*"
},
11 test/app.js
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 () {
2  test/mocha.opts
View
@@ -1 +1 @@
---require should
+--require should-as-global
Please sign in to comment.
Something went wrong with that request. Please try again.