Skip to content

Restore sinon.createStubInstance() behaviour#2075

Merged
mroderick merged 1 commit intosinonjs:masterfrom
kevinbosman:2073-restore-createstubinstance
Sep 2, 2019
Merged

Restore sinon.createStubInstance() behaviour#2075
mroderick merged 1 commit intosinonjs:masterfrom
kevinbosman:2073-restore-createstubinstance

Conversation

@kevinbosman
Copy link
Copy Markdown
Contributor

@kevinbosman kevinbosman commented Aug 14, 2019

Purpose (TL;DR) - mandatory

Fix issue #2073 by reusing createStubInstance() behaviour from stub.js while maintaining the sandbox collection.

Background (Problem in detail) - optional

PR #2022 redirected sinon.createStubInstance() to use the Sandbox implementation thereof. This introduced a breaking change due to the sandbox implementation not supporting property overrides.

Solution - optional

This PR extends sandbox.createStubInstance() to mimic the behaviour of the original sinon.createStubInstance() method.

Instead of duplicating the original createStubInstance() behaviour from stub.js into sandbox.js, it now calls through to the stub.js implementation, then adds all the stubs to the sandbox collection as usual.

The extra tests for property overrides in stub-test.js have also been added to sandbox-test.js to ensure the sandbox implementation now works the same as the original createStubInstance(), while maintaining backward compatibility with all existing sandbox tests.

EDIT: Added some specific tests for issue #2073 in issues-test.js.

How to verify - mandatory

  1. Check out this branch
  2. npm install
  3. npm test

Checklist for author

  • npm run lint passes
  • References to standard library functions are cached.

@coveralls
Copy link
Copy Markdown

coveralls commented Aug 14, 2019

Pull Request Test Coverage Report for Build 2944

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 5 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.002%) to 94.206%

Files with Coverage Reduction New Missed Lines %
sinon/sandbox.js 5 94.96%
Totals Coverage Status
Change from base Build 2939: 0.002%
Covered Lines: 1669
Relevant Lines: 1738

💛 - Coveralls

PR sinonjs#2022 redirected sinon.createStubInstance() to use the Sandbox
implementation thereof. This introduced a breaking change due to the
sandbox implementation not supporting property overrides.

Instead of duplicating the original behaviour from stub.js into
sandbox.js, call through to the stub.js implementation then add all
the stubs to the sandbox collection as usual.

Copy the missing tests from stub-test.js and add issue tests.
@kevinbosman kevinbosman force-pushed the 2073-restore-createstubinstance branch from 2816c27 to a2110fc Compare August 14, 2019 20:32
@fatso83 fatso83 requested a review from mroderick September 2, 2019 10:07
Copy link
Copy Markdown
Member

@mroderick mroderick left a comment

Choose a reason for hiding this comment

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

Excellent work! Thank you for your contribution to Sinon!

@mroderick mroderick merged commit 157b537 into sinonjs:master Sep 2, 2019
@mroderick
Copy link
Copy Markdown
Member

This has been published as sinon@7.4.2 🚢

@kevinbosman kevinbosman deleted the 2073-restore-createstubinstance branch September 2, 2019 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants