2013-08-29 67 views
2

我想要介紹應該斷言庫,工作測試我的node.js應用程序,我的附加功能。如何擴展'應該'庫

喜歡的東西在這個

should  = require "should" 

myExists = (obj, msg) -> 
    # my special exist logic 

containSomething = (obj, msg) -> 
    # my special assert logic 

should.myExists = myExists 
should.containSomething = containSomething 


describe.only "`my extra `", -> 
    it 'should be working', (done) -> 
    obj = {} 
    obj.should.myExists 
    obj.should.not.myExists 
    obj.should.containSomething {cool:obj} 
    obj.should.not.containSomething {cool:obj} 
    done() 

任何建議,如何做到這一點的做法?

+0

你試圖實現它?你做了什麼事? –

+0

@ ben336它不工作。 myExist不存在於對象中。 – Luman75

+0

看起來你有一個錯字。請參閱下面的答案。 –

回答

0
should.myExits = myExists 

也許應該

should.myExist = myExists 
+0

這不是關於錯字問題(我把一個僞代碼),但它是關於用新方法擴展對象。 – Luman75