Skip to content

Commit

Permalink
Merge pull request #1303 from dougo/docs-fixups
Browse files Browse the repository at this point in the history
Docs fixups
  • Loading branch information
cjohansen committed Feb 27, 2017
2 parents 86088bd + c9367aa commit 662f3c1
Show file tree
Hide file tree
Showing 27 changed files with 135 additions and 135 deletions.
4 changes: 2 additions & 2 deletions docs/_releases/v1.17.6/mocks.md
Expand Up @@ -28,7 +28,7 @@ Thus, they enforce implementation details. The rule of thumb is: if you wouldn't

In general you should have **no more than one** mock (possibly with several expectations) in a single test.

[Expectations](#expectations) implement both the [spies](#spies) and [stubs](#stubs) APIs.
[Expectations](#expectations) implement both the [spies](../spies) and [stubs](../stubs) APIs.

To see what mocks look like in Sinon.JS, here is one of the [PubSubJS][pubsubjs] tests again, this time using a method as callback and using mocks to verify its behavior

Expand Down Expand Up @@ -63,7 +63,7 @@ Creates a mock for the provided object.
Does not change the object, but returns a mock object to set expectations on the object's methods.


#### `var expectation = mock.expects(\"method\");`
#### `var expectation = mock.expects("method");`

Overrides `obj.method` with a mock function and returns it.

Expand Down
2 changes: 1 addition & 1 deletion docs/_releases/v1.17.6/sandbox.md
Expand Up @@ -61,7 +61,7 @@ sinon.defaultConfig = {
<dt><code>useFakeServer</code></dt>
<dd>If <code>true</code>, <code>server</code> and <code>requests</code> properties are added to the sandbox. Can also be an object to use for fake server. The default one is <code>sinon.fakeServer</code>, but if you're using jQuery 1.3.x or some other library that does not set the XHR's <code>onreadystatechange</code> handler, you might want to do:

<pre class=\"code-snippet\" data-lang=\"javascript\"><code>sinon.config = {
<pre class="code-snippet" data-lang="javascript"><code>sinon.config = {
useFakeServer: sinon.fakeServerWithClock
};</code></pre></dd>
</dl>
Expand Down
6 changes: 3 additions & 3 deletions docs/_releases/v1.17.6/spies.md
Expand Up @@ -299,7 +299,7 @@ This behaves the same as `spy.neverCalledWith(sinon.match(arg1), sinon.match(arg
Returns `true` if spy threw an exception at least once.


#### `spy.threw(\"TypeError\");`
#### `spy.threw("TypeError");`

Returns `true` if spy threw an exception of the provided type at least once.

Expand All @@ -314,7 +314,7 @@ Returns `true` if spy threw the provided exception object at least once.
Returns `true` if spy always threw an exception.


#### `spy.alwaysThrew(\"TypeError\");`
#### `spy.alwaysThrew("TypeError");`

Returns `true` if spy always threw an exception of the provided type.

Expand Down Expand Up @@ -462,7 +462,7 @@ This behaves the same as `spyCall.notCalledWith(sinon.match(arg1), sinon.match(a
Returns `true` if call threw an exception.


#### `spyCall.threw(TypeError\");`
#### `spyCall.threw("TypeError");`

Returns `true` if call threw exception of provided type.

Expand Down
32 changes: 16 additions & 16 deletions docs/_releases/v1.17.6/stubs.md
Expand Up @@ -8,7 +8,7 @@ breadcrumb: stubs

Test stubs are functions (spies) with pre-programmed behavior.

They support the full <a href="#spies">test spy API</a> in addition to methods which can be used to alter the stub's behavior.
They support the full <a href="../spies">test spy API</a> in addition to methods which can be used to alter the stub's behavior.

As spies, stubs can be either anonymous, or wrap existing functions. When
wrapping an existing function with a stub, the original function is not called.
Expand All @@ -20,7 +20,7 @@ Use a stub when you want to:

1. Control a method's behavior from a test to force the code down a specific path. Examples include forcing a method to throw an error in order to test error handling.

2. When you want to prevent a specific method from being called directly (possibly because it triggers undesired behavior, such as a `XMLHttpRequest or similar).
2. When you want to prevent a specific method from being called directly (possibly because it triggers undesired behavior, such as a `XMLHttpRequest` or similar).

The following example is yet another test from [PubSubJS][pubsubjs] which shows how to create an anonymous stub that throws an exception when called.

Expand Down Expand Up @@ -51,13 +51,13 @@ before one of the other callbacks.

Calling behavior defining methods like `returns` or `throws` multiple times
overrides the behavior of the stub. As of Sinon version 1.8, you can use the
[`onCall`]("#stub-onCall) method to make a stub respond differently on
[`onCall`](#stub-onCall) method to make a stub respond differently on
consecutive calls.

Note that in Sinon version 1.5 to version 1.7, multiple calls to the `yields*`
and `callsArg*` family of methods define a sequence of behaviors for consecutive
calls. As of 1.8, this functionality has been removed in favor of the <a
href="#stub-onCall"><code>onCall</code></a> API.
calls. As of 1.8, this functionality has been removed in favor of the
[`onCall`](#stub-onCall) API.

[pubsubjs]: https://github.com/mroderick/pubsubjs

Expand All @@ -70,19 +70,19 @@ href="#stub-onCall"><code>onCall</code></a> API.
Creates an anonymous stub function


#### `var stub = sinon.stub(object, \"method\");`
#### `var stub = sinon.stub(object, "method");`

Replaces `object.method` with a stub function. An exception is thrown if the property is not already a function.

The original function can be restored by calling `object.method.restore();` (or `stub.restore();`).

#### `var stub = sinon.stub(object, \"method\", func);`
#### `var stub = sinon.stub(object, "method", func);`

Replaces `object.method` with a `func`, wrapped in a `spy`.

As usual, `object.method.restore();` can be used to restore the original method.

#### `name "var stub = sinon.stub(obj);`
#### `var stub = sinon.stub(obj);`

Stubs all the object's methods.

Expand All @@ -96,14 +96,14 @@ If you want to create a stub object of `MyConstructor`, but don't want the const
var stub = sinon.createStubInstance(MyConstructor)
```

#### `name "stub.withArgs(arg1[, arg2, ...]);`
#### `stub.withArgs(arg1[, arg2, ...]);`

Stubs the method only for the provided arguments.

This is useful to be more expressive in your assertions, where you can access the spy with the same call. It is also useful to create a stub that can act differently in response to different arguments.

```javascript
"test should stub method differently based on arguments\": function () {
"test should stub method differently based on arguments": function () {
var callback = sinon.stub();
callback.withArgs(42).returns(1);
callback.withArgs(1).throws("TypeError");
Expand All @@ -114,12 +114,12 @@ This is useful to be more expressive in your assertions, where you can access th
}
```

#### `name "stub.onCall(n);` *Added in v1.8*
#### <a name="stub-onCall"></a>`"stub.onCall(n);` *Added in v1.8*

Defines the behavior of the stub on the *nth* call. Useful for testing sequential interactions.

```javascript
"test should stub method differently on consecutive calls\": function () {
"test should stub method differently on consecutive calls": function () {
var callback = sinon.stub();
callback.onCall(0).returns(1);
callback.onCall(1).returns(2);
Expand All @@ -136,7 +136,7 @@ There are methods `onFirstCall`, `onSecondCall`,`onThirdCall` to make stub defin
`onCall` can be combined with all of the behavior defining methods in this section. In particular, it can be used together with `withArgs`.

```javascript
"test should stub method differently on consecutive calls with certain argument\": function () {
"test should stub method differently on consecutive calls with certain argument": function () {
var callback = sinon.stub();
callback.withArgs(42)
.onFirstCall().returns(1)
Expand Down Expand Up @@ -261,10 +261,10 @@ Like `yields`, `yieldsTo` grabs the first matching argument, finds the callback

#### `stub.yieldsToOn(property, context, [arg1, arg2, ...])`

Like above but with an additional parameter to pass the `this` context."
Like above but with an additional parameter to pass the `this` context.

```javascript
"test should fake successful ajax request\": function () {
"test should fake successful ajax request": function () {
sinon.stub(jQuery, "ajax").yieldsTo("success", [1, 2, 3]);

jQuery.ajax({
Expand All @@ -285,7 +285,7 @@ If the stub was never called with a function argument, `yield` throws an error.
Also aliased as `invokeCallback`.


#### `stub.yieldTo(callback, [arg1, arg2, ...])``
#### `stub.yieldTo(callback, [arg1, arg2, ...])`

Invokes callbacks passed as a property of an object to the stub.

Expand Down
2 changes: 1 addition & 1 deletion docs/_releases/v1.17.6/utils.md
Expand Up @@ -32,7 +32,7 @@ Restores supplied method

Creates a new object with the given function as the protoype and stubs all implemented functions.

The given constructor function is not invoked. See also the [stub API](#stubs).
The given constructor function is not invoked. See also the [stub API](../stubs).

#### `sinon.format(object);`

Expand Down
4 changes: 2 additions & 2 deletions docs/_releases/v1.17.7/mocks.md
Expand Up @@ -28,7 +28,7 @@ Thus, they enforce implementation details. The rule of thumb is: if you wouldn't

In general you should have **no more than one** mock (possibly with several expectations) in a single test.

[Expectations](#expectations) implement both the [spies](#spies) and [stubs](#stubs) APIs.
[Expectations](#expectations) implement both the [spies](../spies) and [stubs](../stubs) APIs.

To see what mocks look like in Sinon.JS, here is one of the [PubSubJS][pubsubjs] tests again, this time using a method as callback and using mocks to verify its behavior

Expand Down Expand Up @@ -63,7 +63,7 @@ Creates a mock for the provided object.
Does not change the object, but returns a mock object to set expectations on the object's methods.


#### `var expectation = mock.expects(\"method\");`
#### `var expectation = mock.expects("method");`

Overrides `obj.method` with a mock function and returns it.

Expand Down
2 changes: 1 addition & 1 deletion docs/_releases/v1.17.7/sandbox.md
Expand Up @@ -61,7 +61,7 @@ sinon.defaultConfig = {
<dt><code>useFakeServer</code></dt>
<dd>If <code>true</code>, <code>server</code> and <code>requests</code> properties are added to the sandbox. Can also be an object to use for fake server. The default one is <code>sinon.fakeServer</code>, but if you're using jQuery 1.3.x or some other library that does not set the XHR's <code>onreadystatechange</code> handler, you might want to do:

<pre class=\"code-snippet\" data-lang=\"javascript\"><code>sinon.config = {
<pre class="code-snippet" data-lang="javascript"><code>sinon.config = {
useFakeServer: sinon.fakeServerWithClock
};</code></pre></dd>
</dl>
Expand Down
6 changes: 3 additions & 3 deletions docs/_releases/v1.17.7/spies.md
Expand Up @@ -299,7 +299,7 @@ This behaves the same as `spy.neverCalledWith(sinon.match(arg1), sinon.match(arg
Returns `true` if spy threw an exception at least once.


#### `spy.threw(\"TypeError\");`
#### `spy.threw("TypeError");`

Returns `true` if spy threw an exception of the provided type at least once.

Expand All @@ -314,7 +314,7 @@ Returns `true` if spy threw the provided exception object at least once.
Returns `true` if spy always threw an exception.


#### `spy.alwaysThrew(\"TypeError\");`
#### `spy.alwaysThrew("TypeError");`

Returns `true` if spy always threw an exception of the provided type.

Expand Down Expand Up @@ -462,7 +462,7 @@ This behaves the same as `spyCall.notCalledWith(sinon.match(arg1), sinon.match(a
Returns `true` if call threw an exception.


#### `spyCall.threw(TypeError\");`
#### `spyCall.threw("TypeError");`

Returns `true` if call threw exception of provided type.

Expand Down
32 changes: 16 additions & 16 deletions docs/_releases/v1.17.7/stubs.md
Expand Up @@ -8,7 +8,7 @@ breadcrumb: stubs

Test stubs are functions (spies) with pre-programmed behavior.

They support the full <a href="#spies">test spy API</a> in addition to methods which can be used to alter the stub's behavior.
They support the full <a href="../spies">test spy API</a> in addition to methods which can be used to alter the stub's behavior.

As spies, stubs can be either anonymous, or wrap existing functions. When
wrapping an existing function with a stub, the original function is not called.
Expand All @@ -20,7 +20,7 @@ Use a stub when you want to:

1. Control a method's behavior from a test to force the code down a specific path. Examples include forcing a method to throw an error in order to test error handling.

2. When you want to prevent a specific method from being called directly (possibly because it triggers undesired behavior, such as a `XMLHttpRequest or similar).
2. When you want to prevent a specific method from being called directly (possibly because it triggers undesired behavior, such as a `XMLHttpRequest` or similar).

The following example is yet another test from [PubSubJS][pubsubjs] which shows how to create an anonymous stub that throws an exception when called.

Expand Down Expand Up @@ -51,13 +51,13 @@ before one of the other callbacks.

Calling behavior defining methods like `returns` or `throws` multiple times
overrides the behavior of the stub. As of Sinon version 1.8, you can use the
[`onCall`]("#stub-onCall) method to make a stub respond differently on
[`onCall`](#stub-onCall) method to make a stub respond differently on
consecutive calls.

Note that in Sinon version 1.5 to version 1.7, multiple calls to the `yields*`
and `callsArg*` family of methods define a sequence of behaviors for consecutive
calls. As of 1.8, this functionality has been removed in favor of the <a
href="#stub-onCall"><code>onCall</code></a> API.
calls. As of 1.8, this functionality has been removed in favor of the
[`onCall`](#stub-onCall) API.

[pubsubjs]: https://github.com/mroderick/pubsubjs

Expand All @@ -70,19 +70,19 @@ href="#stub-onCall"><code>onCall</code></a> API.
Creates an anonymous stub function


#### `var stub = sinon.stub(object, \"method\");`
#### `var stub = sinon.stub(object, "method");`

Replaces `object.method` with a stub function. An exception is thrown if the property is not already a function.

The original function can be restored by calling `object.method.restore();` (or `stub.restore();`).

#### `var stub = sinon.stub(object, \"method\", func);`
#### `var stub = sinon.stub(object, "method", func);`

Replaces `object.method` with a `func`, wrapped in a `spy`.

As usual, `object.method.restore();` can be used to restore the original method.

#### `name "var stub = sinon.stub(obj);`
#### `var stub = sinon.stub(obj);`

Stubs all the object's methods.

Expand All @@ -96,14 +96,14 @@ If you want to create a stub object of `MyConstructor`, but don't want the const
var stub = sinon.createStubInstance(MyConstructor)
```

#### `name "stub.withArgs(arg1[, arg2, ...]);`
#### `stub.withArgs(arg1[, arg2, ...]);`

Stubs the method only for the provided arguments.

This is useful to be more expressive in your assertions, where you can access the spy with the same call. It is also useful to create a stub that can act differently in response to different arguments.

```javascript
"test should stub method differently based on arguments\": function () {
"test should stub method differently based on arguments": function () {
var callback = sinon.stub();
callback.withArgs(42).returns(1);
callback.withArgs(1).throws("TypeError");
Expand All @@ -114,12 +114,12 @@ This is useful to be more expressive in your assertions, where you can access th
}
```

#### `name "stub.onCall(n);` *Added in v1.8*
#### <a name="stub-onCall"></a>`stub.onCall(n);` *Added in v1.8*

Defines the behavior of the stub on the *nth* call. Useful for testing sequential interactions.

```javascript
"test should stub method differently on consecutive calls\": function () {
"test should stub method differently on consecutive calls": function () {
var callback = sinon.stub();
callback.onCall(0).returns(1);
callback.onCall(1).returns(2);
Expand All @@ -136,7 +136,7 @@ There are methods `onFirstCall`, `onSecondCall`,`onThirdCall` to make stub defin
`onCall` can be combined with all of the behavior defining methods in this section. In particular, it can be used together with `withArgs`.

```javascript
"test should stub method differently on consecutive calls with certain argument\": function () {
"test should stub method differently on consecutive calls with certain argument": function () {
var callback = sinon.stub();
callback.withArgs(42)
.onFirstCall().returns(1)
Expand Down Expand Up @@ -261,10 +261,10 @@ Like `yields`, `yieldsTo` grabs the first matching argument, finds the callback

#### `stub.yieldsToOn(property, context, [arg1, arg2, ...])`

Like above but with an additional parameter to pass the `this` context."
Like above but with an additional parameter to pass the `this` context.

```javascript
"test should fake successful ajax request\": function () {
"test should fake successful ajax request": function () {
sinon.stub(jQuery, "ajax").yieldsTo("success", [1, 2, 3]);

jQuery.ajax({
Expand All @@ -285,7 +285,7 @@ If the stub was never called with a function argument, `yield` throws an error.
Also aliased as `invokeCallback`.


#### `stub.yieldTo(callback, [arg1, arg2, ...])``
#### `stub.yieldTo(callback, [arg1, arg2, ...])`

Invokes callbacks passed as a property of an object to the stub.

Expand Down
2 changes: 1 addition & 1 deletion docs/_releases/v1.17.7/utils.md
Expand Up @@ -32,7 +32,7 @@ Restores supplied method

Creates a new object with the given function as the protoype and stubs all implemented functions.

The given constructor function is not invoked. See also the [stub API](#stubs).
The given constructor function is not invoked. See also the [stub API](../stubs).

#### `sinon.format(object);`

Expand Down
4 changes: 2 additions & 2 deletions docs/_releases/v2.0.0-pre.4/mocks.md
Expand Up @@ -28,7 +28,7 @@ Thus, they enforce implementation details. The rule of thumb is: if you wouldn't

In general you should have **no more than one** mock (possibly with several expectations) in a single test.

[Expectations](#expectations) implement both the [spies](#spies) and [stubs](#stubs) APIs.
[Expectations](#expectations) implement both the [spies](../spies) and [stubs](../stubs) APIs.

To see what mocks look like in Sinon.JS, here is one of the [PubSubJS][pubsubjs] tests again, this time using a method as callback and using mocks to verify its behavior

Expand Down Expand Up @@ -63,7 +63,7 @@ Creates a mock for the provided object.
Does not change the object, but returns a mock object to set expectations on the object's methods.


#### `var expectation = mock.expects(\"method\");`
#### `var expectation = mock.expects("method");`

Overrides `obj.method` with a mock function and returns it.

Expand Down
2 changes: 1 addition & 1 deletion docs/_releases/v2.0.0-pre.4/sandbox.md
Expand Up @@ -76,7 +76,7 @@ sinon.defaultConfig = {
<dt><code>useFakeServer</code></dt>
<dd>If <code>true</code>, <code>server</code> and <code>requests</code> properties are added to the sandbox. Can also be an object to use for fake server. The default one is <code>sinon.fakeServer</code>, but if you're using jQuery 1.3.x or some other library that does not set the XHR's <code>onreadystatechange</code> handler, you might want to do:

<pre class=\"code-snippet\" data-lang=\"javascript\"><code>sinon.config = {
<pre class="code-snippet" data-lang="javascript"><code>sinon.config = {
useFakeServer: sinon.fakeServerWithClock
};</code></pre></dd>
</dl>
Expand Down

0 comments on commit 662f3c1

Please sign in to comment.