module Spectator::DSL::Groups

Overview

DSL methods and macros for creating example groups. This module should be included as a mix-in.

Included Modules

Direct including types

Defined in:

spectator/dsl/groups.cr

Macro Summary

Macro Detail

macro context(what, *tags, **metadata, &block) #

Defines a new example group. The what argument is a name or description of the group.

The first argument names the example (test). Typically, this specifies what is being tested. This argument is also used as the subject. When it is a type name, it becomes an explicit, which overrides any previous subjects. Otherwise it becomes an implicit subject, which doesn't override explicitly defined subjects.

Tags can be specified by adding symbols (keywords) after the first argument. Key-value pairs can also be specified. Any falsey items will remove a previously defined tag.

TODO Handle string interpolation in example and group names.


[View source]
macro define_example_group(name, *tags, **metadata) #

Defines a macro to generate code for an example group. The name is the name given to the macro.

Default tags can be provided with tags and metadata. The tags are merged with parent groups. Any items with falsey values from metadata remove the corresponding tag.


[View source]
macro define_iterative_group(name, *tags, **metadata, &block) #

Defines a macro to generate code for an iterative example group. The name is the name given to the macro.

Default tags can be provided with tags and metadata. The tags are merged with parent groups. Any items with falsey values from metadata remove the corresponding tag.

If provided, a block can be used to modify collection that will be iterated. It takes a single argument - the original collection from the user. The modified collection should be returned.

TODO Handle string interpolation in example and group names.


[View source]
macro describe(what, *tags, **metadata, &block) #

Defines a new example group. The what argument is a name or description of the group.

The first argument names the example (test). Typically, this specifies what is being tested. This argument is also used as the subject. When it is a type name, it becomes an explicit, which overrides any previous subjects. Otherwise it becomes an implicit subject, which doesn't override explicitly defined subjects.

Tags can be specified by adding symbols (keywords) after the first argument. Key-value pairs can also be specified. Any falsey items will remove a previously defined tag.

TODO Handle string interpolation in example and group names.


[View source]
macro example_group(what, *tags, **metadata, &block) #

Defines a new example group. The what argument is a name or description of the group.

The first argument names the example (test). Typically, this specifies what is being tested. This argument is also used as the subject. When it is a type name, it becomes an explicit, which overrides any previous subjects. Otherwise it becomes an implicit subject, which doesn't override explicitly defined subjects.

Tags can be specified by adding symbols (keywords) after the first argument. Key-value pairs can also be specified. Any falsey items will remove a previously defined tag.

TODO Handle string interpolation in example and group names.


[View source]
macro fcontext(what, *tags, **metadata, &block) #

Defines a new example group. The what argument is a name or description of the group.

The first argument names the example (test). Typically, this specifies what is being tested. This argument is also used as the subject. When it is a type name, it becomes an explicit, which overrides any previous subjects. Otherwise it becomes an implicit subject, which doesn't override explicitly defined subjects.

Tags can be specified by adding symbols (keywords) after the first argument. Key-value pairs can also be specified. Any falsey items will remove a previously defined tag.

TODO Handle string interpolation in example and group names.


[View source]
macro fdescribe(what, *tags, **metadata, &block) #

Defines a new example group. The what argument is a name or description of the group.

The first argument names the example (test). Typically, this specifies what is being tested. This argument is also used as the subject. When it is a type name, it becomes an explicit, which overrides any previous subjects. Otherwise it becomes an implicit subject, which doesn't override explicitly defined subjects.

Tags can be specified by adding symbols (keywords) after the first argument. Key-value pairs can also be specified. Any falsey items will remove a previously defined tag.

TODO Handle string interpolation in example and group names.


[View source]
macro fexample_group(what, *tags, **metadata, &block) #

Defines a new example group. The what argument is a name or description of the group.

The first argument names the example (test). Typically, this specifies what is being tested. This argument is also used as the subject. When it is a type name, it becomes an explicit, which overrides any previous subjects. Otherwise it becomes an implicit subject, which doesn't override explicitly defined subjects.

Tags can be specified by adding symbols (keywords) after the first argument. Key-value pairs can also be specified. Any falsey items will remove a previously defined tag.

TODO Handle string interpolation in example and group names.


[View source]
macro frandom_sample(collection, *tags, count = nil, **metadata, &block) #

Defines a new iterative example group. This type of group duplicates its contents for each element in collection. This is the same as #sample except that the items are shuffled. The items are selected with a RNG based on the seed.

The first argument is the collection of elements to iterate over.

Tags can be specified by adding symbols (keywords) after the first argument. Key-value pairs can also be specified. Any falsey items will remove a previously defined tag.

The number of items iterated can be restricted by specifying a count argument. The first count items will be used if specified, otherwise all items will be used.


[View source]
macro fsample(collection, *tags, count = nil, **metadata, &block) #

Defines a new iterative example group. This type of group duplicates its contents for each element in collection.

The first argument is the collection of elements to iterate over.

Tags can be specified by adding symbols (keywords) after the first argument. Key-value pairs can also be specified. Any falsey items will remove a previously defined tag.

The number of items iterated can be restricted by specifying a count argument. The first count items will be used if specified, otherwise all items will be used.


[View source]
macro random_sample(collection, *tags, count = nil, **metadata, &block) #

Defines a new iterative example group. This type of group duplicates its contents for each element in collection. This is the same as #sample except that the items are shuffled. The items are selected with a RNG based on the seed.

The first argument is the collection of elements to iterate over.

Tags can be specified by adding symbols (keywords) after the first argument. Key-value pairs can also be specified. Any falsey items will remove a previously defined tag.

The number of items iterated can be restricted by specifying a count argument. The first count items will be used if specified, otherwise all items will be used.


[View source]
macro sample(collection, *tags, count = nil, **metadata, &block) #

Defines a new iterative example group. This type of group duplicates its contents for each element in collection.

The first argument is the collection of elements to iterate over.

Tags can be specified by adding symbols (keywords) after the first argument. Key-value pairs can also be specified. Any falsey items will remove a previously defined tag.

The number of items iterated can be restricted by specifying a count argument. The first count items will be used if specified, otherwise all items will be used.


[View source]
macro xcontext(what, *tags, **metadata, &block) #

Defines a new example group. The what argument is a name or description of the group.

The first argument names the example (test). Typically, this specifies what is being tested. This argument is also used as the subject. When it is a type name, it becomes an explicit, which overrides any previous subjects. Otherwise it becomes an implicit subject, which doesn't override explicitly defined subjects.

Tags can be specified by adding symbols (keywords) after the first argument. Key-value pairs can also be specified. Any falsey items will remove a previously defined tag.

TODO Handle string interpolation in example and group names.


[View source]
macro xdescribe(what, *tags, **metadata, &block) #

Defines a new example group. The what argument is a name or description of the group.

The first argument names the example (test). Typically, this specifies what is being tested. This argument is also used as the subject. When it is a type name, it becomes an explicit, which overrides any previous subjects. Otherwise it becomes an implicit subject, which doesn't override explicitly defined subjects.

Tags can be specified by adding symbols (keywords) after the first argument. Key-value pairs can also be specified. Any falsey items will remove a previously defined tag.

TODO Handle string interpolation in example and group names.


[View source]
macro xexample_group(what, *tags, **metadata, &block) #

Defines a new example group. The what argument is a name or description of the group.

The first argument names the example (test). Typically, this specifies what is being tested. This argument is also used as the subject. When it is a type name, it becomes an explicit, which overrides any previous subjects. Otherwise it becomes an implicit subject, which doesn't override explicitly defined subjects.

Tags can be specified by adding symbols (keywords) after the first argument. Key-value pairs can also be specified. Any falsey items will remove a previously defined tag.

TODO Handle string interpolation in example and group names.


[View source]
macro xrandom_sample(collection, *tags, count = nil, **metadata, &block) #

Defines a new iterative example group. This type of group duplicates its contents for each element in collection. This is the same as #sample except that the items are shuffled. The items are selected with a RNG based on the seed.

The first argument is the collection of elements to iterate over.

Tags can be specified by adding symbols (keywords) after the first argument. Key-value pairs can also be specified. Any falsey items will remove a previously defined tag.

The number of items iterated can be restricted by specifying a count argument. The first count items will be used if specified, otherwise all items will be used.


[View source]
macro xsample(collection, *tags, count = nil, **metadata, &block) #

Defines a new iterative example group. This type of group duplicates its contents for each element in collection.

The first argument is the collection of elements to iterate over.

Tags can be specified by adding symbols (keywords) after the first argument. Key-value pairs can also be specified. Any falsey items will remove a previously defined tag.

The number of items iterated can be restricted by specifying a count argument. The first count items will be used if specified, otherwise all items will be used.


[View source]