#cp.spec.Specification

A Specification is a list of definitions which will be run in sequence, and the results are collated. It is often created via the describe function.

Example usage:

local spec = require "cp.spec" local describe, it = spec.describe, spec.it return describe "a specification" { it "performs an assertion" :doing(function() assert(true, "should not fail") end), }

#API Overview

Functions - API calls offered directly by the extension

Constructors - API calls which return an object, typically one that offers API methods

Methods - API calls which can only be made on an object returned by a constructor


#API Documentation

#Functions

Signaturecp.spec.Specification.is(instance) -> boolean
TypeFunction
DescriptionChecks if the instance is an instance of Specification.
Parameters
  • instance - The instance to check
Returns
  • true if it's a Specification instance.
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/spec/Specification.lua line 31

#Constructors

Signaturecp.spec.Specification(name) -> cp.spec.Specification
TypeConstructor
DescriptionCreates a new test suite.
Parameters
  • name - The name os the specification.
Returns
  • A cp.spec.Specification object
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/spec/Specification.lua line 44

#Methods

Signaturecp.spec.Specification:onAfterEach(afterEachFn) -> cp.spec.Specification
TypeMethod
DescriptionSpecifies a function to execute after each of the contained specifications is run. The function will be passed the Run.This for the current Run.
Parameters
  • afterEachFn - The function to run after each child runs.
Returns
  • The same cp.spec.Specification instance.
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/spec/Specification.lua line 72

Signaturecp.spec.Specification:onBeforeEach(beforeEachFn) -> cp.spec.Specification
TypeMethod
DescriptionSpecifies a function to execute before each of the contained specifications is run. The function will be passed the Run.This for the current Run.
Parameters
  • beforeEachFn - The function to run before each child runs.
Returns
  • The same cp.spec.Specification instance.
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/spec/Specification.lua line 58

Signaturecp.spec.Specification:run() -> cp.spec.Run
TypeMethod
DescriptionRuns the specification, returning the Run instance, already running.
Parameters
  • None
Returns
  • The Run instance.
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/spec/Specification.lua line 86

Signaturecp.spec.Specification:with(...) -> self
TypeMethod
DescriptionAdds the provided definitions to the suite. May also pass a single table containing a list of definitions.
Parameters
Returns
  • The same Specification instance, with the definitions added.
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/spec/Specification.lua line 135