ESpec.Example (ESpec v1.10.0)

View Source

Defines macros 'example' and 'it'. These macros defines function with random name which will be called when example runs. Example structs %ESpec.Example are accumulated in @examples attribute

Summary

Functions

Example struct. description - the description of example, module - spec module, function - random function name, opts - options, file - spec file path, line - the line where example is defined, context - example context. Accumulator for 'contexts' and 'lets', shared - marks example as shared, status - example status (:new, :success, :failure, :pending), result - the value returned by example block or the pending message, error - store an error, duration - test duration.

Context descriptions.

Extracts example options from most specific to least specific as Keyword list. Can include duplicates.

Extracts specific structs from example context.

Extracts example option.

Extracts example options as they are currently valid for this example as map.

Filters failed examples.

Message for pending examples.

Filters pending examples.

Message for skipped examples.

Filters success examples.

Types

t()

@type t() :: %ESpec.Example{
  context: term(),
  description: term(),
  duration: term(),
  error: term(),
  file: term(),
  function: term(),
  line: term(),
  module: term(),
  opts: term(),
  result: term(),
  shared: term(),
  status: term()
}

Functions

%ESpec.Example{}

(struct)

Example struct. description - the description of example, module - spec module, function - random function name, opts - options, file - spec file path, line - the line where example is defined, context - example context. Accumulator for 'contexts' and 'lets', shared - marks example as shared, status - example status (:new, :success, :failure, :pending), result - the value returned by example block or the pending message, error - store an error, duration - test duration.

context_descriptions(example)

Context descriptions.

extract(context, module)

extract_all_options(example)

@spec extract_all_options(t()) :: Keyword.t()

Extracts example options from most specific to least specific as Keyword list. Can include duplicates.

extract_befores(example)

Extracts specific structs from example context.

extract_contexts(example)

extract_finallies(example)

extract_lets(example)

extract_option(example, option)

@spec extract_option(t(), option :: atom()) :: nil | any()

Extracts example option.

extract_options(example)

@spec extract_options(t()) :: %{required(atom()) => any()}

Extracts example options as they are currently valid for this example as map.

failure(results)

Filters failed examples.

pending_message(example)

Message for pending examples.

pendings(results)

Filters pending examples.

skip_message(example)

Message for skipped examples.

success(results)

Filters success examples.