Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1476: stub#firstCall seems broken on sinon v2.3.6 #1478

Merged
merged 3 commits into from
Jul 3, 2017

Conversation

kbtknr
Copy link

@kbtknr kbtknr commented Jun 30, 2017

Fix issue #1476
The cause of this bug is that createCallProperties(matching) is never called in spy.js.

@fatso83
Copy link
Contributor

fatso83 commented Jun 30, 2017

That was quick :-)

@coveralls
Copy link

coveralls commented Jun 30, 2017

Coverage Status

Coverage increased (+0.004%) to 94.998% when pulling 1ff2b9b on takasmiley:issues/#1476 into 8ad2ed7 on sinonjs:master.

Copy link
Member

@fearphage fearphage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few small things to clean up. Thanks for the quick fix! :)

stub.withArgs(1).returns(42);
stub(1);

assert.isObject(stub.withArgs(1).firstCall);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would assert it's not null here. While being an object has the same effect, is not null is a bit more explicit.

test/spy-test.js Outdated
@@ -326,7 +326,62 @@ describe("spy", function () {
});
});

it("counts with combination of withArgs arguments and order of calling withArgs", function () {
it("should work with combination of withArgs arguments and order of calling withArgs", function () {
var assertSpy = function (spy) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just make it a function expression instead. function assertSpy()...

test/spy-test.js Outdated
spy.getCall(2)[propName]);
assert.equals(spy.withArgs(1).getCall(2)[propName],
spy.getCall(3)[propName]);
assert.equals(spy.withArgs(1).getCall(3),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use assert.isNull throughout.

test/spy-test.js Outdated
assert.equals(spy.withArgs(1, 2).callCount, 1);

// assert call
assert.equals(spy.getCall(0).args[0], undefined);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use refute.defined assertion throughout.

@coveralls
Copy link

coveralls commented Jul 3, 2017

Coverage Status

Coverage increased (+0.004%) to 94.998% when pulling 40efa6f on takasmiley:issues/#1476 into 8ad2ed7 on sinonjs:master.

@fatso83 fatso83 merged commit 079925b into sinonjs:master Jul 3, 2017
@fatso83 fatso83 added the semver:patch changes will cause a new patch version label Jul 3, 2017
@jvanoostveen
Copy link

jvanoostveen commented Jul 12, 2017

Hmm it seems with this patch (in 2.3.7) withArgs().lastCall is broken.
TypeError: Cannot read property 'lastCall' of undefined

@fatso83
Copy link
Contributor

fatso83 commented Jul 12, 2017

99 bugs of Sinon on the wall, 99 bugs of Sinon.
Take one down and pass it around, 101 bugs of Sinon on the wall

😭

Seriously, we need some more tests to catch these things. These things are fragile.

@jvanoostveen, could you create an issue with a small reproducible testcase?

P.S. We see all activity on the tracker, so you only need to comment in one issue or cross-reference from the issue you are reporting (Github makes links to the issues when using hash-prefixed issues, such as "#1476").

@jvanoostveen
Copy link

It isn't all bad, I've been very happy with Sinon overall. :)
Sorry about the double post, I wanted to add it to the issue instead of the PR.

After updating from 2.3.5 to 2.3.7 we suddenly have some failing tests. (2.3.6 was also failing, can't remember if they where the same tests.)
I'll try if I make an isolated case with the same error (and post is a new issue, linking to this one/conversation).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver:patch changes will cause a new patch version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants