From 64e563e56e6803ff39ede5edf0759343e4fbebe3 Mon Sep 17 00:00:00 2001 From: Carl-Erik Kopseng Date: Mon, 7 Aug 2017 10:36:23 +0200 Subject: [PATCH] Fix regression on sandbox.stub(obj,protoMethod) closes #1512 --- lib/sinon/collection.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/sinon/collection.js b/lib/sinon/collection.js index 6719931bf..0f369db3f 100644 --- a/lib/sinon/collection.js +++ b/lib/sinon/collection.js @@ -86,7 +86,8 @@ var collection = { }, stub: function stub(object, property) { - if (object && typeof property !== "undefined" && !Object.prototype.hasOwnProperty.call(object, property)) { + if (object && typeof property !== "undefined" + && !(property in object)) { throw new TypeError("Cannot stub non-existent own property " + valueToString(property)); }