module Spectator::SpecBuilder
Overview
Global builder used to create the runtime instance of the spec.
The DSL methods call into this module to generate parts of the spec.
Once the DSL is done, the #build
method can be invoked
to create the entire spec as a runtime instance.
Extended Modules
Defined in:
spectator/spec_builder.crspectator/spec_builder/example_builder.cr
spectator/spec_builder/example_group_builder.cr
spectator/spec_builder/example_group_stack.cr
spectator/spec_builder/nested_example_group_builder.cr
spectator/spec_builder/pending_example_builder.cr
spectator/spec_builder/root_example_group_builder.cr
spectator/spec_builder/runnable_example_builder.cr
spectator/spec_builder/sample_example_group_builder.cr
Instance Method Summary
-
#add_after_all_hook(&block : -> ) : Nil
Adds a block of code to run after all examples in the current group.
-
#add_after_each_hook(&block : TestMetaMethod) : Nil
Adds a block of code to run after each example in the current group.
-
#add_around_each_hook(&block : SpectatorTest, Proc(Nil) -> ) : Nil
Adds a block of code to run before and after each example in the current group.
-
#add_before_all_hook(&block : -> ) : Nil
Adds a block of code to run before all examples in the current group.
-
#add_before_each_hook(&block : TestMetaMethod) : Nil
Adds a block of code to run before each example in the current group.
- #add_default_stub(*args) : Nil
-
#add_example(description : String | Nil, source : Source, example_type : ::SpectatorTest.class, &runner : SpectatorTest -> ) : Nil
Adds an example type to the current group.
-
#add_pending_example(description : String | Nil, source : Source, example_type : ::SpectatorTest.class, &runner : SpectatorTest -> ) : Nil
Adds an example type to the current group.
-
#add_post_condition(&block : TestMetaMethod) : Nil
Adds a post-condition to run at the end of every example in the current group.
-
#add_pre_condition(&block : TestMetaMethod) : Nil
Adds a pre-condition to run at the start of every example in the current group.
-
#end_group : Nil
Marks the end of a group in the spec.
-
#start_group(*args) : Nil
Begins a new nested group in the spec.
-
#start_sample_group(*args, &block : TestValues -> Array(T)) : Nil forall T
Begins a new sample group in the spec - that is, a group defined by the
StructureDSL#sample
macro in the DSL.
Instance Method Detail
Adds a block of code to run after all examples in the current group.
Adds a block of code to run after each example in the current group.
Adds a block of code to run before and after each example in the current group. The block of code will be given another hook as an argument. It is expected that the block will call the hook.
Adds a block of code to run before all examples in the current group.
Adds a block of code to run before each example in the current group.
Adds an example type to the current group. The class name of the example should be passed as an argument. The example will be instantiated later.
Adds an example type to the current group. The class name of the example should be passed as an argument. The example will be instantiated later.
Adds a post-condition to run at the end of every example in the current group.
Adds a pre-condition to run at the start of every example in the current group.
Marks the end of a group in the spec.
This must be called for every #start_group
and #start_sample_group
call.
It is also important to line up the start and end calls.
Otherwise examples might get placed into wrong groups.
Begins a new nested group in the spec.
A corresponding #end_group
call must be made
when the group being started is finished.
See NestedExampleGroupBuilder#initialize
for the arguments
as arguments to this method are passed directly to it.
Begins a new sample group in the spec -
that is, a group defined by the StructureDSL#sample
macro in the DSL.
A corresponding #end_group
call must be made
when the group being started is finished.
See SampleExampleGroupBuilder#initialize
for the arguments
as arguments to this method are passed directly to it.