diff --git a/lib/sinon/spy.js b/lib/sinon/spy.js index b26dd5c7f..cac171374 100644 --- a/lib/sinon/spy.js +++ b/lib/sinon/spy.js @@ -264,7 +264,7 @@ var spyApi = { return false; } - return this.callIds[this.callCount - 1] > spyFn.callIds[spyFn.callCount - 1]; + return this.callIds[this.callCount - 1] > spyFn.callIds[0]; }, calledImmediatelyBefore: function calledImmediatelyBefore(spyFn) { diff --git a/test/spy-test.js b/test/spy-test.js index c8909c65b..6ef323f8b 100644 --- a/test/spy-test.js +++ b/test/spy-test.js @@ -1641,12 +1641,12 @@ describe("spy", function () { assert.isFalse(this.spyA.calledAfter(this.spyB)); }); - it("returns false if other called last", function () { + it("returns true if called anytime after other", function () { this.spyB(); this.spyA(); this.spyB(); - assert.isFalse(this.spyA.calledAfter(this.spyB)); + assert.isTrue(this.spyA.calledAfter(this.spyB)); }); });