Stubbing with arguments

35 views
Skip to first unread message

Mark Hobson

unread,
Mar 23, 2013, 11:06:09 AM3/23/13
to sin...@googlegroups.com
Hi there,

I'm trying to understand whether this fails by design or not:

    var stub = sinon.stub().withArgs(42).returns("yes");
    assert(stub(42) === "yes");
    assert(stub(13) === undefined);

The second assertion fails as it still returns "yes".  Breaking the stub creation into two steps fixes it:

    var stub = sinon.stub();
    stub.withArgs(42).returns("yes");

Is the DSL supposed to work in this way or is there a bug?

Thanks,

Mark

Christian Johansen

unread,
Mar 25, 2013, 3:46:45 AM3/25/13
to sin...@googlegroups.com
That looks like a bug to me.

Christian
Reply all
Reply to author
Forward
0 new messages