diff --git a/src/spectator/dsl/builder.cr b/src/spectator/dsl/builder.cr index 0180333..98d9e4e 100644 --- a/src/spectator/dsl/builder.cr +++ b/src/spectator/dsl/builder.cr @@ -3,7 +3,7 @@ module Spectator module Builder extend self - @group_stack = [ExampleGroupBuilder.new] + @group_stack = [::Spectator::DSL::ExampleGroupBuilder.new] private def current_group @group_stack.last @@ -15,18 +15,21 @@ module Spectator end def start_group(what : String) : Nil - push_group(ExampleGroupBuilder.new(what)) + group = ::Spectator::DSL::ExampleGroupBuilder.new(what) + push_group(group) end def start_given_group(what : String, values : Array(ValueWrapper)) : Nil - push_group(GivenExampleGroupBuilder.new(what, values)) + group = ::Spectator::DSL::GivenExampleGroupBuilder.new(what, values) + push_group(group) end def end_group : Nil @group_stack.pop end - def add_example(factory : AbstractExampleFactory) : Nil + def add_example(example_type : Example.class) : Nil + factory = ::Spectator::DSL::ExampleGroupBuilder.new(example_type) current_group.add_child(factory) end @@ -52,7 +55,7 @@ module Spectator protected def build : Array(Example) # TODO - ExampleGroup.new + [] of Example end end end diff --git a/src/spectator/dsl/structure_dsl.cr b/src/spectator/dsl/structure_dsl.cr index bfb11da..3b04f3b 100644 --- a/src/spectator/dsl/structure_dsl.cr +++ b/src/spectator/dsl/structure_dsl.cr @@ -38,13 +38,13 @@ module Spectator %collection.first end - @%wrapper : ValueWrapper + @%wrapper : ::Spectator::ValueWrapper def {{block.args.empty? ? "value".id : block.args.first}} - @%wrapper.as(TypedValueWrapper(typeof(%first))).value + @%wrapper.as(::Spectator::TypedValueWrapper(typeof(%first))).value end - def initialize(locals : Hash(Symbol, ValueWrapper)) + def initialize(locals : Hash(Symbol, ::Spectator::ValueWrapper)) super @%wrapper = locals[:%group] end @@ -94,14 +94,14 @@ module Spectator macro let(name, &block) let!(%value) {{block}} - @%wrapper : ValueWrapper? + @%wrapper : ::Spectator::ValueWrapper? def {{name.id}} if (wrapper = @%wrapper) - wrapper.unsafe_as(TypedValueWrapper(typeof(%value))).value + wrapper.unsafe_as(::Spectator::TypedValueWrapper(typeof(%value))).value else %value.tap do |value| - @%wrapper = TypedValueWrapper(typeof(%value)).new(value) + @%wrapper = ::Spectator::TypedValueWrapper(typeof(%value)).new(value) end end end @@ -142,7 +142,7 @@ module Spectator include ::Spectator::DSL::ExampleDSL include {{@type.id}} - def initialize(locals : Hash(Symbol, ValueWrapper)) + def initialize(locals : Hash(Symbol, ::Spectator::ValueWrapper)) super end @@ -161,13 +161,11 @@ module Spectator end def group - ::Spectator::Definitions::GROUPS[{{@type.symbolize}}] + nil # TODO end end - ::Spectator::DSL::Builder.add_example_factory( - ::Spectator::DSL::ExampleFactory(Example%example).new - ) + ::Spectator::DSL::Builder.add_example(Example%example) end macro pending(description, &block) diff --git a/src/spectator/value_wrapper.cr b/src/spectator/value_wrapper.cr index d84a39e..95e294f 100644 --- a/src/spectator/value_wrapper.cr +++ b/src/spectator/value_wrapper.cr @@ -2,7 +2,7 @@ module Spectator # Base class for proxying test values to examples. # This abstraction is required for inferring types. # The `DSL#let` macro makes heavy use of this. - private abstract class ValueWrapper + abstract class ValueWrapper # Retrieves the underlying value. abstract def value end