diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index 07e0eabc..2d4f32e8 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -2195,12 +2195,7 @@ getJasmineRequireObj().matchersUtil = function(j$) { } return false; } - if (!haystack) { - return false; - } else { - var indexOf = haystack.indexOf || Array.prototype.indexOf; - return indexOf.call(haystack, needle) >= 0; - } + return !!haystack && haystack.indexOf(needle) >= 0; }, buildFailureMessage: function() { diff --git a/spec/core/matchers/matchersUtilSpec.js b/spec/core/matchers/matchersUtilSpec.js index f5b7f20c..4a981a13 100644 --- a/spec/core/matchers/matchersUtilSpec.js +++ b/spec/core/matchers/matchersUtilSpec.js @@ -207,15 +207,6 @@ describe("matchersUtil", function() { it("fails when actual is null", function() { expect(j$.matchersUtil.contains(null, 'A')).toBe(false); }); - - it("passes with array-like objects", function() { - var capturedArgs = null; - function testFunction(){ - capturedArgs = arguments; - } - testFunction('foo', 'bar'); - expect(j$.matchersUtil.contains(capturedArgs, 'bar')).toBe(true); - }); }); describe("buildMessage", function() { diff --git a/src/core/matchers/matchersUtil.js b/src/core/matchers/matchersUtil.js index 488c337b..b6fb8383 100644 --- a/src/core/matchers/matchersUtil.js +++ b/src/core/matchers/matchersUtil.js @@ -19,12 +19,7 @@ getJasmineRequireObj().matchersUtil = function(j$) { } return false; } - if (!haystack) { - return false; - } else { - var indexOf = haystack.indexOf || Array.prototype.indexOf; - return indexOf.call(haystack, needle) >= 0; - } + return !!haystack && haystack.indexOf(needle) >= 0; }, buildFailureMessage: function() {