diff --git a/lib/gently/gently.js b/lib/gently/gently.js index 75329ba..4338d90 100644 --- a/lib/gently/gently.js +++ b/lib/gently/gently.js @@ -185,11 +185,13 @@ Gently.prototype._stubFn = function(self, obj, method, name, args) { Gently.prototype._name = function(obj, method, stubFn) { if (obj) { - var objectName = obj.toString(); - if (objectName == '[object Object]' && obj.constructor.name) { - objectName = '[' + obj.constructor.name + ']'; + let objectName + if (typeof obj === 'function' && obj.name) { + objectName = obj.name; + } else { + objectName = obj.toString(); } - return (objectName) + '.' + method + '()'; + return objectName + '.' + method + '()'; } if (stubFn.name) {