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

Fix utils.inspect with custom object-returning inspect()s. #173

Merged
merged 1 commit into from
Jun 14, 2013

Conversation

domenic
Copy link
Contributor

@domenic domenic commented Jun 14, 2013

This code is lifted from the latest node utils.js: https://github.com/joyent/node/blob/896b2aa7074fc886efd7dd0a397d694763cac7ce/lib/util.js#L205-L209

Without it, if an object contains another object whose custom inspect() method returns a non-string, utils.inspect gets confused and tries to do nonString.indexOf.

This fixes chaijs/chai-as-promised#32, where Chai as Promised was trying to call utils.inspect on an AssertionError which contained as its "actual" property a Q promise. Since Q promises have custom inspect methods that return objects, not strings, this was triggered.


Would love a patch release with this soon :)

This code is lifted from the latest node utils.js: https://github.com/joyent/node/blob/896b2aa7074fc886efd7dd0a397d694763cac7ce/lib/util.js#L205-L209

Without it, if an object contains another object whose custom `inspect()` method returns a non-string, `utils.inspect` gets confused and tries to do `nonString.indexOf`.

This fixes chaijs/chai-as-promised#32, where Chai as Promised was trying to call `utils.inspect` on an `AssertionError` which contained as its "actual" property a Q promise. Since Q promises have custom `inspect` methods that return objects, not strings, this was triggered.
logicalparadox added a commit that referenced this pull request Jun 14, 2013
Fix `utils.inspect` with custom object-returning inspect()s.
@logicalparadox logicalparadox merged commit b95038b into master Jun 14, 2013
@logicalparadox
Copy link
Member

Will release later today once I figure out what is going on with phantomjs tests.

@logicalparadox logicalparadox deleted the inspect-fix branch June 17, 2013 20:07
@logicalparadox
Copy link
Member

Released with 1.7.0. View the release notes.

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

Successfully merging this pull request may close these issues.

Tests failing with TypeError (Object has no method 'indexOf')
2 participants