mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Root example group specialization
This commit is contained in:
parent
3facf3af9d
commit
2070d7816b
4 changed files with 32 additions and 5 deletions
|
@ -2,11 +2,9 @@ module Spectator::DSL
|
||||||
module Builder
|
module Builder
|
||||||
extend self
|
extend self
|
||||||
|
|
||||||
@@group_stack = [::Spectator::DSL::ExampleGroupBuilder.new("ROOT")]
|
@@group_stack = Array(ExampleGroupBuilder).new(1, root_group)
|
||||||
|
|
||||||
private def root_group
|
private class_getter root_group = RootExampleGroupBuilder.new()
|
||||||
@@group_stack.first
|
|
||||||
end
|
|
||||||
|
|
||||||
private def current_group
|
private def current_group
|
||||||
@@group_stack.last
|
@@group_stack.last
|
||||||
|
@ -57,7 +55,7 @@ module Spectator::DSL
|
||||||
end
|
end
|
||||||
|
|
||||||
protected def build : ExampleGroup
|
protected def build : ExampleGroup
|
||||||
root_group.build(nil, Internals::SampleValues.empty)
|
root_group.build(Internals::SampleValues.empty)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
15
src/spectator/dsl/root_example_group_builder.cr
Normal file
15
src/spectator/dsl/root_example_group_builder.cr
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
module Spectator::DSL
|
||||||
|
class RootExampleGroupBuilder < ExampleGroupBuilder
|
||||||
|
def initialize
|
||||||
|
super("ROOT")
|
||||||
|
end
|
||||||
|
|
||||||
|
def build(sample_values : Internals::SampleValues) : ExampleGroup
|
||||||
|
RootExampleGroup.new(build_hooks).tap do |group|
|
||||||
|
group.children = @children.map do |child|
|
||||||
|
child.build(group, sample_values).as(ExampleGroup::Child)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -18,6 +18,7 @@ require "./pending_example"
|
||||||
|
|
||||||
require "./example_hooks"
|
require "./example_hooks"
|
||||||
require "./example_group"
|
require "./example_group"
|
||||||
|
require "./root_example_group"
|
||||||
|
|
||||||
require "./expectation_failed"
|
require "./expectation_failed"
|
||||||
require "./test_results"
|
require "./test_results"
|
||||||
|
|
13
src/spectator/root_example_group.cr
Normal file
13
src/spectator/root_example_group.cr
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
require "./example_group"
|
||||||
|
|
||||||
|
module Spectator
|
||||||
|
class RootExampleGroup < ExampleGroup
|
||||||
|
def initialize(hooks)
|
||||||
|
super("ROOT", nil, hooks)
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_s(io)
|
||||||
|
# ...
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue