mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Bit of code cleanup
This commit is contained in:
parent
bff6d463df
commit
ab146c88c2
5 changed files with 8 additions and 8 deletions
|
@ -4,7 +4,7 @@ module Spectator::DSL
|
||||||
|
|
||||||
@@group_stack = Array(ExampleGroupBuilder).new(1, root_group)
|
@@group_stack = Array(ExampleGroupBuilder).new(1, root_group)
|
||||||
|
|
||||||
private class_getter root_group = RootExampleGroupBuilder.new()
|
private class_getter root_group = RootExampleGroupBuilder.new
|
||||||
|
|
||||||
private def current_group
|
private def current_group
|
||||||
@@group_stack.last
|
@@group_stack.last
|
||||||
|
@ -16,12 +16,12 @@ module Spectator::DSL
|
||||||
end
|
end
|
||||||
|
|
||||||
def start_group(*args) : Nil
|
def start_group(*args) : Nil
|
||||||
group = ::Spectator::DSL::NestedExampleGroupBuilder.new(*args)
|
group = NestedExampleGroupBuilder.new(*args)
|
||||||
push_group(group)
|
push_group(group)
|
||||||
end
|
end
|
||||||
|
|
||||||
def start_given_group(*args) : Nil
|
def start_given_group(*args) : Nil
|
||||||
group = ::Spectator::DSL::GivenExampleGroupBuilder.new(*args)
|
group = GivenExampleGroupBuilder.new(*args)
|
||||||
push_group(group)
|
push_group(group)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ module Spectator::DSL
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_example(example_type : Example.class) : Nil
|
def add_example(example_type : Example.class) : Nil
|
||||||
factory = ::Spectator::DSL::ExampleFactory.new(example_type)
|
factory = ExampleFactory.new(example_type)
|
||||||
current_group.add_child(factory)
|
current_group.add_child(factory)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ module Spectator::DSL
|
||||||
@around_each_hooks << block
|
@around_each_hooks << block
|
||||||
end
|
end
|
||||||
|
|
||||||
private def build_hooks
|
private def hooks
|
||||||
ExampleHooks.new(
|
ExampleHooks.new(
|
||||||
@before_all_hooks,
|
@before_all_hooks,
|
||||||
@before_each_hooks,
|
@before_each_hooks,
|
||||||
|
|
|
@ -7,7 +7,7 @@ module Spectator::DSL
|
||||||
end
|
end
|
||||||
|
|
||||||
def build(parent : ExampleGroup, sample_values : Internals::SampleValues) : NestedExampleGroup
|
def build(parent : ExampleGroup, sample_values : Internals::SampleValues) : NestedExampleGroup
|
||||||
NestedExampleGroup.new(@what, parent, build_hooks).tap do |group|
|
NestedExampleGroup.new(@what, parent, hooks).tap do |group|
|
||||||
group.children = @collection.map do |value|
|
group.children = @collection.map do |value|
|
||||||
build_sub_group(group, sample_values, value).as(ExampleComponent)
|
build_sub_group(group, sample_values, value).as(ExampleComponent)
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,7 +8,7 @@ module Spectator::DSL
|
||||||
end
|
end
|
||||||
|
|
||||||
def build(parent : ExampleGroup, sample_values : Internals::SampleValues) : NestedExampleGroup
|
def build(parent : ExampleGroup, sample_values : Internals::SampleValues) : NestedExampleGroup
|
||||||
NestedExampleGroup.new(@what, parent, build_hooks).tap do |group|
|
NestedExampleGroup.new(@what, parent, hooks).tap do |group|
|
||||||
group.children = @children.map do |child|
|
group.children = @children.map do |child|
|
||||||
child.build(group, sample_values).as(ExampleComponent)
|
child.build(group, sample_values).as(ExampleComponent)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
module Spectator::DSL
|
module Spectator::DSL
|
||||||
class RootExampleGroupBuilder < ExampleGroupBuilder
|
class RootExampleGroupBuilder < ExampleGroupBuilder
|
||||||
def build(sample_values : Internals::SampleValues) : RootExampleGroup
|
def build(sample_values : Internals::SampleValues) : RootExampleGroup
|
||||||
RootExampleGroup.new(build_hooks).tap do |group|
|
RootExampleGroup.new(hooks).tap do |group|
|
||||||
group.children = @children.map do |child|
|
group.children = @children.map do |child|
|
||||||
child.build(group, sample_values).as(ExampleComponent)
|
child.build(group, sample_values).as(ExampleComponent)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue