Sha256: 43e705f67e6c539a24c4a7871fce200aa431b643866164500d79245cb6ecb150
Contents?: true
Size: 1.41 KB
Versions: 6
Compression:
Stored size: 1.41 KB
Contents
/* global jasmine */ 'use strict'; (function(jasmine, beforeEach) { var spyMatchers = 'called calledOnce calledTwice calledThrice calledBefore calledAfter calledOn alwaysCalledOn calledWith alwaysCalledWith calledWithExactly alwaysCalledWithExactly calledWithMatch alwaysCalledWithMatch'.split(' '), i = spyMatchers.length, spyMatcherHash = {}, unusualMatchers = { "returned": "toHaveReturned", "alwaysReturned": "toHaveAlwaysReturned", "threw": "toHaveThrown", "alwaysThrew": "toHaveAlwaysThrown" }, getMatcherFunction = function(sinonName, matcherName) { var original = jasmine.Matchers.prototype[matcherName]; return function () { if (jasmine.isSpy(this.actual) && original) { return original.apply(this, arguments); } var sinonProperty = this.actual[sinonName]; return (typeof sinonProperty === 'function') ? sinonProperty.apply(this.actual, arguments) : sinonProperty; }; }; while(i--) { var sinonName = spyMatchers[i], matcherName = "toHaveBeen" + sinonName.charAt(0).toUpperCase() + sinonName.slice(1); spyMatcherHash[matcherName] = getMatcherFunction(sinonName, matcherName); } for (var j in unusualMatchers) { spyMatcherHash[unusualMatchers[j]] = getMatcherFunction(j, unusualMatchers[j]); } beforeEach(function() { this.addMatchers(spyMatcherHash); }); })(jasmine, beforeEach);
Version data entries
6 entries across 6 versions & 1 rubygems