module

Spectator::DSL::Groups

Inherits Spectator::DSL::Metadata

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

Macros

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.

Source
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.

Source
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.

Source
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.

Source
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.

Source
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.

Source
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.

Source
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.

Source
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.

Source
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.

Source
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.

Source
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.

Source
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.

Source
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.

Source
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.

Source
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.

Source
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.

Source