`assert.match` should not be calling every method on an object it's matching against
Closed this issue · 2 comments
This is in the light of reviewing results of the fix for #64
assert.match
will try to use assert.match
on every property of the objects. Which means that if said property is a function - it will call assert.match(actualObj[someProp], expectedObj[someProp])
. If expectedObj[someProp]
is a function, match
will call that function: var fn = expectedObj[someProp]; fn(actualObj[someProp])
... That's just a bad idea, as you may imagine :)
Just opening up a discussion for now. Head is busy with too many things, to suggest a good solution for now.
Had a quick look and figured hey - if and object's method is the same, then it matches, and if it isn't - then it doesn't. But apparently all functions are treated as matchers, even when they're nested: https://github.com/dominykas/samsam/blob/master/test/samsam-test.js#L326
I could implement it so that if the matcher property is a function, and the object property is a function, and they're both the same function - it matches, and if it's not the same function - use it as a matcher. But wouldn't this be kind of too magic?
In short the options are:
- Do magic
- Break existing behaviour of nested matchers
- Close this as won't fix
stalebot-ing myself.