Sha256: 6501a5020979e8c4924d61e64db5f2c8a92ce39efb25eff65ffc8f44debf5c68

Contents?: true

Size: 1.18 KB

Versions: 2

Compression:

Stored size: 1.18 KB

Contents

(function(global) {

  var spyMatchers = "called calledOnce calledTwice calledThrice calledBefore calledAfter calledOn alwaysCalledOn calledWith alwaysCalledWith calledWithExactly alwaysCalledWithExactly".split(" "),
    i = spyMatchers.length,
    spyMatcherHash = {},
    unusualMatchers = {
      "returned": "toHaveReturned",
      "alwaysReturned": "toHaveAlwaysReturned",
      "threw": "toHaveThrown",
      "alwaysThrew": "toHaveAlwaysThrown"
    },

  getMatcherFunction = function(sinonName) {
    return function() {
      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);
  };

  for (var j in unusualMatchers) {
    spyMatcherHash[unusualMatchers[j]] = getMatcherFunction(j);
  }

  global.sinonJasmine = {
    getMatchers: function() {
      return spyMatcherHash;
    }
  };

})(window);

beforeEach(function() {

  this.addMatchers(sinonJasmine.getMatchers());

});

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rails-backbone-generator-0.0.3 lib/generators/backbone/setup_generator/templates/vendor/assets/javascripts/testing/jasmine-sinon.js
rails-backbone-generator-0.0.1 lib/generators/backbone/templates/vendor/javascripts/testing/jasmine-sinon.js