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

Import nise #1461

Merged
merged 8 commits into from
Jul 27, 2017
Merged

Import nise #1461

merged 8 commits into from
Jul 27, 2017

Conversation

mroderick
Copy link
Member

@mroderick mroderick commented Jun 17, 2017

This PR is part of #1453, it replaces fake xhr and fake server with nise

To try it out

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

@mroderick mroderick added the semver:major changes will cause a new major version label Jun 17, 2017
@mroderick
Copy link
Member Author

Added the MAJOR label because:

  • 944f6cf removes previously deprecated properties
  • We might break something

It's better that people only get this release through conscious upgrade, and not part of regular install (damn you loose versioning!!!!)

@fearphage
Copy link
Member

  • 944f6cf removes previously deprecated properties

FYI these changes should end up int he release notes.

@coveralls
Copy link

coveralls commented Jul 10, 2017

Coverage Status

Coverage increased (+0.5%) to 95.452% when pulling 2395f35 on mroderick:import-nise into 9365d49 on sinonjs:master.

@mroderick
Copy link
Member Author

I have pushed new commits that imports the new nise module from npm.

There are still some deprecations we can remove:

Shall we remove them as part of this MAJOR release, or save them for another day?

@coveralls
Copy link

coveralls commented Jul 10, 2017

Coverage Status

Coverage increased (+0.5%) to 95.452% when pulling 69cc06a on mroderick:import-nise into 9365d49 on sinonjs:master.

@fatso83
Copy link
Contributor

fatso83 commented Jul 11, 2017

Remove, remove, remove!

@fatso83
Copy link
Contributor

fatso83 commented Jul 12, 2017

I think we can merge this and remove any remaining deprecations in another PR. Anyone opposed?

@mroderick
Copy link
Member Author

Anyone opposed?

Me! I am already working on removing the last deprecations, so I'd rather just keep this branch open for a bit longer, than either have master unshippable again or having to maintain another legacy branch.

@mroderick
Copy link
Member Author

OK, I think I have mopped up all the previously deprecated stuff.

If we're going to put out a new MAJOR release based on this PR, then I think it deserves a thorough review.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.4%) to 95.381% when pulling 59a87e6 on mroderick:import-nise into 259a330 on sinonjs:master.

@mroderick
Copy link
Member Author

I am attending a family event today, so won't be able to contribute anything until tonight at the earliest and perhaps not even until sometime next week.

@coveralls
Copy link

coveralls commented Jul 15, 2017

Coverage Status

Coverage increased (+0.4%) to 95.381% when pulling 5eca462 on mroderick:import-nise into 259a330 on sinonjs:master.

@mroderick
Copy link
Member Author

Ping @sinonjs/core do you have any further comments for this PR?

@fatso83
Copy link
Contributor

fatso83 commented Jul 22, 2017

Njet. All good.

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 like missing tests. But the biggest thign I see is missing documentation about what is being removed.

if (arguments.length > 2) {
return sandboxStub.apply(this, arguments);
throw new TypeError("stub(obj, 'meth', fn) has been removed, see documentation");
Copy link
Member

Choose a reason for hiding this comment

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

Remove the duplication. This will still get thrown on line 97 below.

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed, well spotted

@@ -3,15 +3,13 @@
var valueToString = require("./util/core/value-to-string");
var hasOwnProperty = Object.prototype.hasOwnProperty;

function stubNonFunctionProperty(object, property, value) {
function stubNonFunctionProperty(object, property) {
Copy link
Member

Choose a reason for hiding this comment

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

2 things:

  1. This should throw like the other stub method with too many arguments.
  2. The replacement for this usage is not documented (like stub(...).callFake(fn)).

Copy link
Member Author

Choose a reason for hiding this comment

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

This should throw like the other stub method with too many arguments.

It is internal only, and is called inside sandbox.stub, which does throw for too many arguments.

Copy link
Member Author

Choose a reason for hiding this comment

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

The replacement for this usage is not documented

The practice of using sandbox.stub for stubbing out properties has been documented for awhile, admittedly, not very well.

Copy link
Member Author

Choose a reason for hiding this comment

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

I have pushed another commit to improve documentation for stubbing out non-function properties

var original = object[property];

if (!hasOwnProperty.call(object, property)) {
throw new TypeError("Cannot stub non-existent own property " + valueToString(property));
}

object[property] = value;
Copy link
Member

Choose a reason for hiding this comment

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

Looks like most of the property tests were removed. I see negative tests, but no positive tests.

Copy link
Member Author

Choose a reason for hiding this comment

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

Stubbing properties is the responsibility of collection.js, it has several tests covering this.

@@ -2,7 +2,6 @@

module.exports = {
calledInOrder: require("./called-in-order"),
configureLogError: require("./log_error"),
Copy link
Member

Choose a reason for hiding this comment

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

If this was accessible, we should document that it was removed even if it was previously deprecated.

@@ -49,20 +41,13 @@ exports.useFakeTimers = fakeTimers.useFakeTimers;
exports.clock = fakeTimers.clock;
exports.timers = fakeTimers.timers;

var event = require("./sinon/util/event");
exports.Event = deprecated.wrap(event.Event, deprecated.defaultMsg("Event"));
Copy link
Member

Choose a reason for hiding this comment

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

Documentation for all of these changes.


// This is deprecated and will be removed in a future version of sinon.
// We will only consider pull requests that fix serious bugs in the implementation
function stubDescriptor(object, property, descriptor) {
Copy link
Member

Choose a reason for hiding this comment

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

Documentation.

Copy link
Member Author

Choose a reason for hiding this comment

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

This was an internal only file.

That sinon.stub only accepts two arguments has been documented in this very commit

@@ -597,6 +597,7 @@ describe("sinonSandbox", function () {

it("allows stubbing setters", function () {
var object = {
foo: undefined,
Copy link
Member

Choose a reason for hiding this comment

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

Did this need to be added?

Copy link
Member Author

Choose a reason for hiding this comment

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

It is necessary, otherwise we run into the input validation of collection.stub, that checks for own properties on stubbing targets.

TypeError: Cannot stub non-existent own property foo

@coveralls
Copy link

coveralls commented Jul 24, 2017

Coverage Status

Coverage increased (+0.4%) to 95.434% when pulling 0570deb on mroderick:import-nise into 259a330 on sinonjs:master.

@mroderick
Copy link
Member Author

@fearphage thank you for your thorough review.

I think I have addressed all your comments.

If you're satisfied, then I'll fold the review commit into the appropriate commit and merge it.

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.

Are all the event deprecations and removals documented? It looks good for the most part besides my doc concerns.

I also noticed a bum test, but I unblocked the PR.

}});

assert.equals(obj.prop, 43);
var stub = createStub(obj, "prop");
Copy link
Member

Choose a reason for hiding this comment

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

This test has no assertions now. Add an assertion or remove the test.

Copy link
Member Author

Choose a reason for hiding this comment

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

That was a mistake! I've fixed this in the offending commit and have rebased my branch

@fatso83 fatso83 mentioned this pull request Jul 25, 2017
@coveralls
Copy link

coveralls commented Jul 26, 2017

Coverage Status

Coverage increased (+0.4%) to 95.434% when pulling 1ef9e71 on mroderick:import-nise into 20eb865 on sinonjs:master.

@mroderick
Copy link
Member Author

I think everything has been addressed. Since #1496 is also a MAJOR, I would like to merge that one first and then this one, and then just cut one new MAJOR release, instead of two.

@mroderick mroderick merged commit 40f1599 into sinonjs:master Jul 27, 2017
@mroderick mroderick deleted the import-nise branch July 27, 2017 07:54
@mroderick mroderick mentioned this pull request Jul 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver:major changes will cause a new major version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants