Bit of code cleanup

This commit is contained in:
Michael Miller 2018-10-14 17:43:33 -06:00
parent bff6d463df
commit ab146c88c2
5 changed files with 8 additions and 8 deletions

View file

@ -4,7 +4,7 @@ module Spectator::DSL
@@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
@@group_stack.last
@ -16,12 +16,12 @@ module Spectator::DSL
end
def start_group(*args) : Nil
group = ::Spectator::DSL::NestedExampleGroupBuilder.new(*args)
group = NestedExampleGroupBuilder.new(*args)
push_group(group)
end
def start_given_group(*args) : Nil
group = ::Spectator::DSL::GivenExampleGroupBuilder.new(*args)
group = GivenExampleGroupBuilder.new(*args)
push_group(group)
end
@ -30,7 +30,7 @@ module Spectator::DSL
end
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)
end

View file

@ -33,7 +33,7 @@ module Spectator::DSL
@around_each_hooks << block
end
private def build_hooks
private def hooks
ExampleHooks.new(
@before_all_hooks,
@before_each_hooks,

View file

@ -7,7 +7,7 @@ module Spectator::DSL
end
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|
build_sub_group(group, sample_values, value).as(ExampleComponent)
end

View file

@ -8,7 +8,7 @@ module Spectator::DSL
end
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|
child.build(group, sample_values).as(ExampleComponent)
end

View file

@ -1,7 +1,7 @@
module Spectator::DSL
class RootExampleGroupBuilder < ExampleGroupBuilder
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|
child.build(group, sample_values).as(ExampleComponent)
end