With an array of regular expression, it seems that toContain is always true.
This test case fails:
it("is crazy", function()
var array = ;
var p1 = /1/i;
var p2 = /2/i;
The error message says Error: Expected [ /2/i ] not to contain /1/i.. If .not is removed, the test case pass.
Error: Expected [ /2/i ] not to contain /1/i.
I took a little closer look into the case and it seems that the regex is the main issue here, matching objects and other variables seems to be fine. Also note that the regex issue extends to other matchers like toEqual.
what happens is that the content of the array is identified as an object and is compared in that way. problem is the structure of a RegExp object is different from what the jasmine.Env.compareObjects_ expects and fails to do a compare that is reliable.
I propose adding a check to jasmine.Env.equals_ to do if (a instanceof RegExp && b instanceof RegExp). there should be no other side effects as this would only apply for both a and b being a RegExp and comparing an object with the RegExp does give back a reliable false.
if (a instanceof RegExp && b instanceof RegExp)
I'm still not a 100% sure how to compare the regexp properly but it is likely that I will turn it into a string like it is done in data comparison. Working on it!
resolving issue that was identified via jasmine/jasmine#199 where Reg…
…Exp objects were not properly compared resulting in non-matching RegExp objects to always return true. a patch to jasmine.Env.equals_ adds an extra step for RexExp objects to be compared.
@alightgoesout pull request has been accepted and is merged into master. Issue can be closed