[ospec] allow spy to wrap functions

This commit is contained in:
Barney Carroll 2016-08-30 17:10:21 +01:00
parent 9c4ebc8667
commit 211802793d
2 changed files with 21 additions and 1 deletions

View file

@ -19,11 +19,14 @@ module.exports = new function init() {
ctx = parent
}
o.only = function(subject, predicate) {o(subject, only = predicate)}
o.spy = function() {
o.spy = function(fn) {
var spy = function() {
spy.this = this
spy.args = [].slice.call(arguments)
spy.callCount++
if(fn)
return fn.apply(this, arguments)
}
spy.args = []
spy.callCount = 0