jupiter / simple-mock

Super simple stubs and spies with 1-step sandbox restore
MIT License
87 stars 12 forks source link

Convert stub.loop to a function #15

Closed natlibfi-arlehiko closed 8 years ago

natlibfi-arlehiko commented 8 years ago

Stub methods chain be chained since they return the stub object. However, stub.loop is not a function but a variable. Consider changing it to a function (I can look into implementing the change if you find this reasonable).

Examples

Variable

var stub = simple.stub().returnWith('bar');
mock = {
  foo: stub
};

stub.loop = false;

Function

var mock = {
  foo: simple.stub().loop(false).returnWith('bar')
};
HCanber commented 8 years ago

Changing it would be a breaking change, so it's probably better to add new functions that can be chained. What about something like: stub.noLoop() equals stub.loop = false stub.withLoop() equals stub.loop = true