Hi,
Is there an easy way for stubbing a chain of methods in sinon? Say I have something like this:
Message.find().populate().exec(function(err, results) {
if(err) {
// ...
}
else {
// ...
}
});
To simulate the success and error scenarios for exec(), I basically need to stub the find() method with something like this:
sinon.stub(Message, 'find', function() {
return {
populate: function() {
return {
exec: function(errorCb) {
errorCb(null, []);
}
}
}
};
});
While this works, I'm wondering if Sinon provides a shorter and more concise way for stubbing a chain of methods. I'm looking at similar to stub_chain of RSpec:
http://www.relishapp.com/rspec/rspec-mocks/v/3-2/docs/old-syntax/stub-chainRegards,
Diwa