Skip to content

Commit

Permalink
Add docs for the new API get and set behaviors
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfcosta committed Mar 11, 2017
1 parent eb7f90f commit ad58467
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions docs/release-source/release/stubs.md
Expand Up @@ -448,3 +448,38 @@ var stub = sinon.stub().returnsNum(42);

assert.equals(stub(), 42);
```

#### `stub.get(getterFn)`

Replaces a new getter for this stub.

```javascript
var myObj = {
prop: 'foo'
};

createStub(myObj, 'prop').get(function getterFn() {
return 'bar';
});

myObj.example; // 'bar'
```

#### `stub.set(setterFn)`

Defines a new setter for this stub.

```javascript
var myObj = {
example: 'oldValue',
prop: 'foo'
};

createStub(myObj, 'prop').set(function setterFn(val) {
myObj.example = val;
});

myObj.prop = 'baz';

myObj.example; // 'baz'
```

0 comments on commit ad58467

Please sign in to comment.