Comparing version 0.1.3 to 0.1.4
@@ -35,9 +35,14 @@ /* | ||
var methods = Object.getOwnPropertyNames(obj); | ||
if (obj.constructor !== Object) { | ||
obj = obj.constructor.prototype; | ||
_.forEach(obj.constructor.prototype, function(value, property) { | ||
methods.push(property); | ||
}); | ||
} | ||
_.forEach(obj, function(value, property) { | ||
var member = typeof(value); | ||
_.forEach(methods, function(value) { | ||
var member = typeof(obj[value]); | ||
if (member === 'function') { | ||
funcs.push(property); | ||
funcs.push(value); | ||
} | ||
@@ -78,7 +83,7 @@ }); | ||
function calledOnce() { | ||
assert.equal(timesCalled, 1); | ||
assert.equal(timesCalled, 1); | ||
} | ||
function calledTwice() { | ||
assert.equal(timesCalled, 2); | ||
assert.equal(timesCalled, 2); | ||
} | ||
@@ -94,3 +99,3 @@ | ||
never: never, | ||
once : calledOnce, | ||
once: calledOnce, | ||
twice: calledTwice, | ||
@@ -97,0 +102,0 @@ withArgs: withArgs |
{ | ||
"name": "deride", | ||
"description": "Mocking library based on composition", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"homepage": "https://github.com/REAANDREW/deride", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -176,2 +176,5 @@ # deride [![Build Status](https://travis-ci.org/REAANDREW/deride.svg?branch=master)](https://travis-ci.org/REAANDREW/deride) [![NPM version](https://badge.fury.io/js/deride.svg)](http://badge.fury.io/js/deride) ![Dependencies Status](https://david-dm.org/reaandrew/deride.png) | ||
### v0.1.4 - 24nd April 2014 | ||
Bug fixes and support for different method definition styles | ||
## License | ||
@@ -178,0 +181,0 @@ Copyright (c) 2014 Andrew Rea |
@@ -34,4 +34,4 @@ /* | ||
describe('Excpectations', function(){ | ||
it('does not invoke original method when override method body', function(){ | ||
describe('Excpectations', function() { | ||
it('does not invoke original method when override method body', function() { | ||
@@ -42,7 +42,7 @@ var obj = deride.stub(['send']); | ||
obj = deride.wrap(obj); | ||
obj.setup.send.toDoThis(function(){ | ||
obj.setup.send.toDoThis(function() { | ||
return 'hello'; | ||
}); | ||
var result = obj.send(); | ||
assert.equal(result,'hello'); | ||
assert.equal(result, 'hello'); | ||
}); | ||
@@ -57,2 +57,12 @@ }); | ||
}, { | ||
name: 'Wrapping existing objects with Object style methods', | ||
setup: function() { | ||
var Person = { | ||
greet: function(name) { | ||
return 'alice sas hello to ' + name; | ||
} | ||
}; | ||
return Person; | ||
} | ||
}, { | ||
name: 'Wrapping existing object using Object Freeze with expectations', | ||
@@ -102,3 +112,3 @@ setup: function() { | ||
it('enables convenience method for called.once', function(done){ | ||
it('enables convenience method for called.once', function(done) { | ||
bob = deride.wrap(bob); | ||
@@ -110,3 +120,3 @@ bob.greet('alice'); | ||
it('enables convenience method for called.twice', function(done){ | ||
it('enables convenience method for called.twice', function(done) { | ||
bob = deride.wrap(bob); | ||
@@ -140,3 +150,3 @@ bob.greet('alice'); | ||
//result.should.eql('yo alice'); | ||
assert.equal(result,'yo alice'); | ||
assert.equal(result, 'yo alice'); | ||
done(); | ||
@@ -150,3 +160,3 @@ }); | ||
//result.should.eql('foobar'); | ||
assert.equal(result,'foobar'); | ||
assert.equal(result, 'foobar'); | ||
done(); | ||
@@ -160,3 +170,3 @@ }); | ||
bob.greet('alice'); | ||
},/BANG/); | ||
}, /BANG/); | ||
done(); | ||
@@ -175,4 +185,4 @@ }); | ||
var result2 = bob.greet('bob'); | ||
assert.equal(result1,'yo yo alice'); | ||
assert.equal(result2,'yo bob'); | ||
assert.equal(result1, 'yo yo alice'); | ||
assert.equal(result2, 'yo bob'); | ||
done(); | ||
@@ -187,4 +197,4 @@ }); | ||
var result2 = bob.greet('bob'); | ||
assert.equal(result1,'foobar'); | ||
assert.equal(result2,'barfoo'); | ||
assert.equal(result1, 'foobar'); | ||
assert.equal(result2, 'barfoo'); | ||
done(); | ||
@@ -199,6 +209,6 @@ }); | ||
bob.greet('alice'); | ||
},/BANG/); | ||
}, /BANG/); | ||
assert.doesNotThrow(function() { | ||
bob.greet('bob'); | ||
},/BANG/); | ||
}, /BANG/); | ||
done(); | ||
@@ -205,0 +215,0 @@ }); |
24015
447
184