Describes a single piece of behaviour
var Example = require('nodespec/lib/example').Example;
In general an Example should not be instantiated directly, and instead created via ExampleGroup.example.
Example | Describes a single piece of behaviour |
Constructors | |
Example | |
Constants | |
DEFAULT_TIMEOUT | Defaults to 5 seconds |
Properties | |
description | The description of this example |
full_description | The full description, parent’s description + this example’s |
file_path | The file where this example was declared |
line_number | The line number where this example was declared. |
Functions | |
toString | Useful string representation of the example |
timeout_after | Modify the execution timeout |
exec | Execute this example |
function Example( description, options, block )
description | {string} The title of the behaviour being described |
options | {options} See below |
block | {function} The spec definition, can be prodcedural or asynchronous. See ExampleGroup.example. |
options.timeout | {nunber} seconds before assuming spec has stalled |
options.group | The parent ExampleGroup of this spec |
options.nodespec | The top-level nodespec function |
options.deps | {options} Constructor function dependency injection |
options.deps.Context | constructor function for context |
options.deps.SingleResult | constructor function for one result |
options.deps.Pending | constructor function for pending exception |
Example.prototype.exec = function( emitter, callback/*(err, result)*/ )
Execute this example
All before hooks defined will be executed in sequence, followed by the example, followed by all of the after hooks. Any defined subjects will be available to the example’s context.
emitter | {EventEmitter} events from execution will be fired on this emitter |
callback | {function} Callback fired on completion of execution |
callback.err | {Error} undefined or an exception object |
callback.result | {<SingleResult>} The result of the execution |
exampleStart (Example) | Example about to be executed |
exampleComplete (Example, err) | Example has finished execution |
examplePass (Example) | Example has passed |
exampleFail (Example, err) | Example has failed |
examplePend (Example, err) | Example is pending |
exampleError (Example, err) | Example has errored |
function Example( description, options, block )
Useful string representation of the example
Example.prototype.toString = function()
Modify the execution timeout
Example.prototype.timeout_after = function( seconds )
Execute this example
Example.prototype.exec = function( emitter, callback/*(err, result)*/ )
Define an Example to be executed against this group
ExampleGroup.prototype.example = function( description, options, block )
Create another top-level nodespec container, keyed by name
function nodespec( name, deps )