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

stub(obj, 'meth', fn) has been removed, see documentation #1761

Closed
ericmorand opened this issue Apr 2, 2018 · 10 comments
Closed

stub(obj, 'meth', fn) has been removed, see documentation #1761

ericmorand opened this issue Apr 2, 2018 · 10 comments

Comments

@ericmorand
Copy link

When I use the following code, I have an error:

let obj = {
    foo: function() {
    }
}
var stub = sinon.stub(obj , "foo", () => {});

stub(obj, 'meth', fn) has been removed, see documentation

I then check the documentation:

http://sinonjs.org/releases/v2.0.0/stubs/#var-stub--sinonstubobject-method-func

var stub = sinon.stub(object, "method", func);

Replaces object.method with a func, wrapped in a spy.

As usual, object.method.restore(); can be used to restore the original method.

I'm using sinon 4.3.

@ericmorand
Copy link
Author

ericmorand commented Apr 2, 2018

Forget about it, for some reason Google search "sinon stub" point to the 2.0.0 documentation.

@alangpierce
Copy link

alangpierce commented May 2, 2018

For those finding this by Google searching the error message, the updated docs are here: http://sinonjs.org/releases/v5/stubs/

It looks like the new form is stub(obj, 'meth').callsFake(fn):

var stub = sinon.stub(object, "method", func);
This has been removed from v3.0.0. Instead you should use
stub(obj, 'meth').callsFake(fn)
A codemod is available to upgrade your code

@fatso83
Copy link
Contributor

fatso83 commented May 2, 2018

@mroderick: It's unfortunate that people end up creating issues due to our (?) SEO strategy, so maybe it's time to look at the suggestion I once had for fixing the out of date Google searches. I could start out with detailing the issue and a potential fix (as per our Twitter discussion of .. 2016?).

AFAI remember the suggested fix was doing something like Django, that foresakes some semantic correctness through canonical link manipulation to improve SEO by always having Google hits point to /latest. The details escape me ATM, but it was conceptually simple. It is just doing it using Jekyll that was the hurdle, AFAI can recall :-)

@mantoni
Copy link
Member

mantoni commented May 3, 2018

Would it be possible to have a banner at the top of old versions stating that these docs are outdated? That wouldn’t improve the search results, but at least it’s more obvious to visitors.

@fatso83
Copy link
Contributor

fatso83 commented May 3, 2018

@mantoni Yeah, exactly one of the things that came up in my Twitter exchange with Morgan:


Btw, I have had second doubts about this due to some SEO concerns. I think we need another approach, ref this question: https://webmasters.stackexchange.com/questions/109113/versioned-pages-making-sure-google-points-to-the-current … which led me to this: https://webmasters.stackexchange.com/questions/99867/how-to-correctly-mark-up-different-versions-of-the-same-document-which-are-non-c

Basically, I think a big improvement for better Google hits would be to do what Django does in their docs:https://webmasters.stackexchange.com/a/101534/11903 - use rel=canonical to basically wipe all but the latest versions from the index - have a small alert at the top alerting the user that they are looking at older docs.

@mroderick
Copy link
Member

I think that using banners and canonical (or noindex) would be a good start.

Ultimately, I'd like to have a better documentation website.

  • easier to manage, easier to contribute to (it's getting unwieldy with all the releases)
  • more examples, basically every method/property should have at least one good usage example
  • playground

@hansyulian
Copy link

as for today, i still come to this as the top google search result for stub(obj, 'meth', fn) has been removed, see documentation

@nabilfreeman
Copy link

Made it here after upgrading Sinon from v2 to v11 (!!!!!!!)

Thanks for explaining the required refactor 👍

@lsh-0
Copy link

lsh-0 commented Aug 24, 2022

For those finding this by Google searching the error message, the updated docs are here: http://sinonjs.org/releases/v5/stubs/

The change seems to have occurred in v3, not v5, and the updated docs are now here:

@fatso83
Copy link
Contributor

fatso83 commented Aug 24, 2022

The change seems to have occurred in v3, not v5, and the updated docs are now here:

We deprecated it in version 2 and removed it in version 3, yes :-)

P.S. Updated the links mentioned in the comments, since we decided to just keep docs per major version.

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

No branches or pull requests

8 participants