diff options
| author | mo k <mo@mokhan.ca> | 2012-05-21 12:17:47 -0600 |
|---|---|---|
| committer | mo k <mo@mokhan.ca> | 2012-05-21 12:17:47 -0600 |
| commit | e604d780bb3a12657c0dc89419a3c8ecf49e0e9e (patch) | |
| tree | 6be9189c89bcf6183135e82dbce037613c6c26a1 | |
| parent | c5bb8e11918394ab864595f968cda276ae532508 (diff) | |
throw error when a matcher is not found.
| -rw-r--r-- | spec/javascripts/FakeSpec.js | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/spec/javascripts/FakeSpec.js b/spec/javascripts/FakeSpec.js index 3645c9b..cbfe3e0 100644 --- a/spec/javascripts/FakeSpec.js +++ b/spec/javascripts/FakeSpec.js @@ -3,9 +3,8 @@ describe ("Fake", function() { sut = new Fake(); }); var sut; - describe ("when stubbing out return values", function() { - describe ("when there is no args", function() { + describe ("when there are no parameters", function() { it ("should return the correct value", function() { expect(result).toEqual("hello"); }); @@ -17,15 +16,23 @@ describe ("Fake", function() { }); describe ("when there are arguments to match", function() { describe ("when there is a single input argument", function() { - it ("should return the value the corresponds to the input arguments", function() { - expect(sut.greet('mo')).toEqual('hello mo'); + describe ("when invoked as expected", function() { + it ("should return the value the corresponds to the input arguments", function() { + expect(sut.greet('mo')).toEqual('hello mo'); + }); + it ("should return the correct value that corresponds to other args", function() { + expect(sut.greet('jo')).toEqual('hello jo'); + }); + beforeEach (function() { + sut.stub('greet').with('mo').andReturn('hello mo'); + sut.stub('greet').with('jo').andReturn('hello jo'); + }); }); - it ("should return the correct value that corresponds to other args", function() { - expect(sut.greet('jo')).toEqual('hello jo'); - }); - beforeEach (function() { - sut.stub('greet').with('mo').andReturn('hello mo'); - sut.stub('greet').with('jo').andReturn('hello jo'); + describe ("when invoked unexpectedly", function() { + it ("should throw an error", function() { + sut.stub('greet').with('mo').andReturn('hello mo'); + expect(function(){sut.greet('malcolm');}).toThrow("Matcher not found."); + }); }); }); }); |
