From 1d46a198ed2872830a1f521c166636a19534ecc3 Mon Sep 17 00:00:00 2001 From: Yomi Colledge Date: Wed, 14 Dec 2011 23:05:19 +0000 Subject: [PATCH 1/2] Adding jasmine-sinon to the mix --- vendor/assets/javascripts/jasmine-sinon.js | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 vendor/assets/javascripts/jasmine-sinon.js diff --git a/vendor/assets/javascripts/jasmine-sinon.js b/vendor/assets/javascripts/jasmine-sinon.js new file mode 100644 index 0000000..91ddd9b --- /dev/null +++ b/vendor/assets/javascripts/jasmine-sinon.js @@ -0,0 +1,44 @@ +/** + jasmine-sinon.js 0.1.0 +**/ +(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" + }, + + 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()); + +}); From 1f8102a2ed85d31f6984af2d782b720fd2afc993 Mon Sep 17 00:00:00 2001 From: Yomi Colledge Date: Wed, 14 Dec 2011 23:10:29 +0000 Subject: [PATCH 2/2] Updating README.md to include jasmine-sinon --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 5928d0b..cb16734 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ Works in jasmine-headless-webkit versions that support Sprockets. It comes with the libraries I need: * [jasmine-jquery](https://github.com/velesin/jasmine-jquery) 1.3.1 +* [jasmine-sinon](https://github.com/froots/jasmine-sinon) 0.1.0 * [Sinon.js](http://sinonjs.org/) 1.2.0 ## How to use it @@ -16,6 +17,7 @@ It's Sprockets vendored gem goodness, so at the top of your `spec_helper`: ``` coffee #= require jasmine-jquery #= require sinon +#= require jasmine-sinon ...make cool code... ```