Tobi incompatible with should-style Chai #76

zzen opened this Issue Feb 24, 2012 · 2 comments

3 participants

tobi = require('tobi')
chai = require('chai').should()

Produces an error:

TypeError: Property 'should' of object #<Object> is not a function
    at Object.<anonymous> (/Users/jakub/Documents/apiary/
    at Object.<anonymous> (/Users/jakub/Documents/apiary/
    at Module._compile (module.js:404:26)
    at (/Users/jakub/.nvm/v0.4.7/lib/node_modules/coffee-script/lib/coffee-script/coffee-script.js:68:25)
    at /Users/jakub/.nvm/v0.4.7/lib/node_modules/coffee-script/lib/coffee-script/command.js:135:29
    at /Users/jakub/.nvm/v0.4.7/lib/node_modules/coffee-script/lib/coffee-script/command.js:110:18
    at [object Object].<anonymous> (fs.js:107:5)
    at [object Object].emit (events.js:61:17)
    at afterRead (fs.js:878:12)
    at wrapper (fs.js:245:17)

The opposite require order works fine. This is super non-intuitive, just spent the last 30mins debugging this.

The reason for this is that tobi tries to require should.js, should.js extends Object.prototype including nuking the setter for the Object.prototype.should property. A while later, chai#should also tries to extend Object.prototype in the same way but is blocked by the empty setter.

Since should.js seems to be a convenience anyway, could we remove it out of the instantiation (perhaps make the attaching of tobi extensions to should.js optional?)



Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment