Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Made expectations accept calls with any arguments when with_arguments…

… is not used.

Signed-off-by: Andy Kent <andrew.d.kent@gmail.com>
  • Loading branch information...
commit ef828a2ec97f2e1659200c33a8d0bc15b9f810b5 1 parent bb3d0e0
Irene Morente authored andykent committed
Showing with 14 additions and 2 deletions.
  1. +2 −2 lib/smoke.mock.js
  2. +12 −0 spec/mock_spec.js
View
4 lib/smoke.mock.js
@@ -55,7 +55,7 @@ Smoke.Mock.Expectation = function(mock, attr) {
this._attr = attr;
this.callCount = 0;
this.returnValue = undefined;
- this.callerArgs = [];
+ this.callerArgs = undefined;
};
Smoke.Mock.Expectation.prototype = {
@@ -78,7 +78,7 @@ Smoke.Mock.Expectation.prototype = {
return this
},
run: function(args){
- if(this.compareArrays(args, this.callerArgs)) {
+ if(typeof(this.callerArgs) == 'undefined' || this.compareArrays(args, this.callerArgs)) {
this.callCount+=1;
return this.returnValue;
};
View
12 spec/mock_spec.js
@@ -12,6 +12,12 @@ Screw.Unit(function() {
m.bar();
m.bar();
});
+
+ it("should not check arguments when with_arguments is not used", function() {
+ var m = mock()
+ m.should_receive('bar').exactly('once');
+ m.bar(1);
+ });
it("should check a minimum call count", function() {
var m = mock()
@@ -57,6 +63,12 @@ Screw.Unit(function() {
mockObj.should_receive('foo').with_arguments('bar').exactly('once');
mockObj.foo('bar')
});
+ it("should only mock the exact method signature when with_arguments is used with no arguments", function() {
+ mockObj = mock();
+ mockObj.should_receive('foo').with_arguments().exactly('once');
+ mockObj.foo('should ignore this call');
+ mockObj.foo();
+ });
});
describe("added ontop of an existing object", function() {
Please sign in to comment.
Something went wrong with that request. Please try again.