diff --git a/spec/core/SpySpec.js b/spec/core/SpySpec.js index fb90657f..55adb7c7 100644 --- a/spec/core/SpySpec.js +++ b/spec/core/SpySpec.js @@ -20,6 +20,13 @@ describe('Spies', function () { expect(spy.bob).toEqual("test"); }); + it("should allow you to omit the name argument and only pass the originalFn argument", function() { + var fn = function test() {}; + var spy = env.createSpy(fn); + + expect(spy.and.identity).toEqual("test"); + }) + it("warns the user that we intend to overwrite an existing property", function() { TestClass.prototype.someFunction.and = "turkey"; diff --git a/src/core/Env.js b/src/core/Env.js index 74b31829..c351f7b9 100644 --- a/src/core/Env.js +++ b/src/core/Env.js @@ -474,6 +474,11 @@ getJasmineRequireObj().Env = function(j$) { }; this.createSpy = function(name, originalFn) { + if (arguments.length === 1 && j$.isFunction_(name)) { + originalFn = name; + name = originalFn.name; + } + return spyFactory.createSpy(name, originalFn); };