class Spectator::DSL::SampleExampleGroupBuilder(C, T)
- Spectator::DSL::SampleExampleGroupBuilder(C, T)
- Spectator::DSL::NestedExampleGroupBuilder
- Spectator::DSL::ExampleGroupBuilder
- Reference
- Object
Overview
Specialized example group builder for "sample" groups.
The type parameter C
is the type to instantiate to create the collection.
The type parameter T
should be the type of each element in the sample collection.
This builder creates a container group with groups inside for each item in the collection.
The hooks are only defined for the container group.
By doing so, the hooks are defined once, are inherited, and use less memory.
Defined in:
spectator/dsl/sample_example_group_builder.crConstructors
-
.new(what : String, collection_type : C.class, collection_builder : C -> Array(T), name : String, symbol : Symbol)
Creates a new group builder.
Instance Method Summary
-
#build(parent : ExampleGroup, sample_values : Internals::SampleValues) : NestedExampleGroup
Builds the example group.
Instance methods inherited from class Spectator::DSL::NestedExampleGroupBuilder
build(parent : ExampleGroup, sample_values : Internals::SampleValues) : NestedExampleGroup
build
Constructor methods inherited from class Spectator::DSL::NestedExampleGroupBuilder
new(what : Symbol | String)
new
Instance methods inherited from class Spectator::DSL::ExampleGroupBuilder
add_after_all_hook(block : -> ) : Nil
add_after_all_hook,
add_after_each_hook(block : -> ) : Nil
add_after_each_hook,
add_around_each_hook(block : Proc(Nil) -> ) : Nil
add_around_each_hook,
add_before_all_hook(block : -> ) : Nil
add_before_all_hook,
add_before_each_hook(block : -> ) : Nil
add_before_each_hook,
add_child(child : Child)
add_child,
add_post_condition(block : -> ) : Nil
add_post_condition,
add_pre_condition(block : -> ) : Nil
add_pre_condition
Instance methods inherited from class Object
should(matcher : Spectator::Matchers::Matcher)
should,
should_not(matcher : Spectator::Matchers::Matcher)
should_not
Constructor Detail
Creates a new group builder. The value for what should be the text the user specified for the collection. The collection_type is the type to create that will produce the items. The collection_builder is a proc that takes an instance of collection_type and returns an actual array of items to create examples for. The name is the variable name that the user accesses the current collection item with.
In this code:
sample random_integers do |integer|
# ...
end
The what would be "random_integers" and the collection would contain the items returned by calling random_integers. The name would be "integer".
The symbol is passed along to the sample values so that the example code can retrieve the current item from the collection. The symbol should be unique.
Instance Method Detail
Builds the example group.
A new NestedExampleGroup
will be returned
which can have instances of Example
and ExampleGroup
nested in it.
The parent should be the group that contains this group.
The sample_values will be given to all of the examples (and groups) nested in this group.