visionmedia/should.js — Issue #40: Stubs and mocks
Author: Skinney
Created: 2012-01-16 08:49:07+00:00
State: open

Hi!

I would love to have the ability to be able to stub or mock any object in Should.js. I could implement this myself, but as I have limited time I would rather not waste it if no-one things stubs or mocks should be a part of Should.js at all. Before anyone says anything, yes I know I can use a third party framework like Sinon, but I'd rather this kind of functionality would be a part of the actual assert-framework than anything else.

Implementing this kind of functionality into Should allows us to automatically revert stubs when the test is done, without imposing additional syntax.

I was thinking having something like object.should.be.stubbed().should.return(42).if.called.with("id", "peterson");
which is basically three operations, stub the object, assert return value of 42, assert function is called with arguments "id" and "peterson".

What do people think? Is this something people would want as a part of the Should framework, or as a standalone framework?