Closed rprieto closed 10 years ago
Idea is good, but i would like to do not add jsonpath
as dependency.
What i would suggest is something like this:
person.should.have.propertyByPath('address', 'home', 'city').eql('London')
(just path
could confuse, i think)
Fair point! For the syntax I guess the dot notation could be syntactic sugar that just calls String.split('.')
I will close this as it already in master (will publish today or at weekend). If you have issues about it, pls create new one in shouldjs/should.js.
That's great thanks! So is shouldjs/should.js taking over visionmedia/should.js as the official repo?
Yes, i made TJ the admin of that org, i will add 2 others current maintainers as soon i reach them (but they are not too active to work on should.js).
+1
Testing nested properties, it seems we currently have a choice between:
or the probably better option:
That's better, but a little cumbersome, and still not quite as descriptive as I hoped. What if we could have:
Alternatively, it could support JSONPath, in which case it's just a matter of executing the path and running the assertion of every match. The exception could (if possible) print the path of the failing properties.
Happy to give it a try for a PR, or make it a separate module if that's preferred.