diff options
| author | mo k <mo@mokhan.ca> | 2012-05-21 11:08:49 -0600 |
|---|---|---|
| committer | mo k <mo@mokhan.ca> | 2012-05-21 11:08:49 -0600 |
| commit | 7e15845e5089850d2882850d288bf6dd298e59e7 (patch) | |
| tree | cfbbed20c7b4c0588accfd712658234091aeb143 | |
| parent | 1d0e2de27d8716cdfc409e1d16157aa2e53e4f98 (diff) | |
create simple stub method.
| -rw-r--r-- | spec/javascripts/FakeSpec.js | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/spec/javascripts/FakeSpec.js b/spec/javascripts/FakeSpec.js new file mode 100644 index 0000000..0bf6c1b --- /dev/null +++ b/spec/javascripts/FakeSpec.js @@ -0,0 +1,37 @@ +describe ("Fake", function() { + beforeEach (function() { + sut = new Fake(); + }); + var sut; + describe ("when stubbing out return values", function() { + describe ("when there is no args", function() { + it ("should return the correct value", function() { + expect(result).toEqual("hello mo"); + }); + beforeEach (function() { + sut.stub('greet').andReturn('hello mo'); + result = sut.greet(); + }); + var result; + }); + }); +}); +var Fake = (function(){ + var fake = function(){ + methods = []; + this.stub = function(method){ + methods.push(method); + return this; + }; + this.andReturn = function(return_value){ + var method = methods[methods.length - 1]; + console.log(method); + this[method] = function(){ + return return_value; + }; + }; + }; + return function(){ + return new fake(); + }; +})(); |
