-
-
Notifications
You must be signed in to change notification settings - Fork 35
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
Add assertions/matchers for sinon #25
Comments
Hey again! Adding support for Sinon to Must.js itself is probably outside its scope, but please do let me know how I can help make it easy for you to create a plugin for it. :-) Let's carry the plugin conversation in an older issue, #12. Thanks again! |
@moll, I know Also, I know that with the exception of
Would you be okay with that? This would considerably simplify my plugin. |
Hey! Yeah, need a little bit of tweaking of So, back to your Sinon matchers. Well, I can't stop you from adding First, it doesn't really make it more readable — it contains the same amount of characters and the separation between a dotted Second, [{a: 1}, {b: 2}].must.always.have.property("a") The above looks as if it works, but really doesn't. Which reminds me, you'll be coming up against the same always-never problem as described in #6. That is, the You'll probably end up having to make |
I've been wanting to add spy.must.have.alwaysBeenCalledWith(model)
spy.must.have.had.thisValues.equal(model)
spy.thisValues.must.all.equal(model)
|
TL;DR ... you have been warned. ;-) First, I'd like to say thanks for the work on Now, I think I must respectfully disagree with some of your comments above, unless of course I'm completely misinterpreting the intention behind having community developed plugins. IMHO:
With regards to some of your comments:
Yes, that is exactly the point. The plugin is meant to be used specifically with Sinon and its modifier properties are not intended to be used outside the Sinon domain.
I guess the examples I provided aren't representative of my intended syntax. The idea was for: spy.must.have.been.alwaysCalledWith(context) to read as: spy.must.have.always.been.calledWith(context) ... so the assertion of more English-like.
Yes, that is exactly what it does and what it means. It should succeed no matter how many times This won't necessarily be true for all plugins. There may be plugins which add matchers and properties that are universally applicable, but I don't think that should be the rule because that would considerable limit the fluidity of the assertion syntax a plugin could create for a particular domain. All this being said, once the community starts creating the likelihood of collisions between plugins will be inevitable. While all plugins MUST be compatible with Must.js, they may not necessarily be compatible with all other plugins. As it stands right now, since the current architecture requires plugins to inject themselves into Must.js, it would be the plugin's responsibility to detect/handle any such collisions. That, IMHO, creates a significant amount of unnecessary boilerplate/overhead for the plugin. In addition to the fact that plugin developers may not (either by choice or ignorance) properly handle collision detection. Personally, I would have preferred if Must.js provided a unified interface for plugins. An interface that will:
I believe such an interface would not only simplify by also promote plugin development. A single/unified interface would be much easier to debug as well. Imagine 10 different plugins with 10 different mechanisms to inject themselves into Must.js. The addition of |
One of the reasons I had preferred chai to must in the past was it's ecosystem of community provided plugins. sinon-chai is one that I use frequently. I hope we can agree on a way to achieve #24, so that we can start providing equivalent plugins for
must
.The text was updated successfully, but these errors were encountered: