2013-08-29 3 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

이것은 오타 (pseudo) 코드를 넣는 문제가 아니라 새로운 방법으로 Object를 확장하는 것에 관한 것입니다. – Luman75