Enable should interface attaching to arbitrary root object #257

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
2 participants

I'm having problems using the should interface with selenium-webdriver. I think the problem is that the whole library for some reason runs in its own vm context. Sort of speak it has a parallel object hierarchy, so the Object that should attaches to is not the one that all selenium objects (namely promises) inherit.

With this patch should can be attached to an arbitrary object, by calling chai.should(obj). In the selenium use-case the object that did the trick was to do chai.should(webdriver.promise.Promise), because all promises inherit from this one. I'm also using chai-as-promised, but that is unrelated.

To check the selenium code go to the _base.js file inside the selenium-webdriver node package (I couldn't find a replica of that in a repository posted online, the official webdriver repo has nothing to do with the published tree...).

Owner

keithamus commented Nov 6, 2014

Seems like a fairly reasonable change... I'm just not entirely convinced by the use case. It sounds like such an esoteric use case, that it might just be worth monkey-patching for just this instance, rather than merging code in.

I'll leave this PR open - in case anyone else wants to chime in and convince me.

Owner

keithamus commented May 3, 2015

@ichernev I'm going to close this one for now - because it has been hanging around for a while and I'm still not entirely convinced of its utility - especially, as I've said, I think it would be simple to monkey patch for when it is necessary. Hopefully you understand, and I hope you don't let this put you off of contributing to chai more!

@keithamus keithamus closed this May 3, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment