Pass along class type instead of collection
This commit is contained in:
parent
01c4b78716
commit
34b5487e6f
|
@ -41,10 +41,10 @@ module Spectator::DSL
|
||||||
# that is, a group defined by the `StructureDSL#sample` macro in the DSL.
|
# that is, a group defined by the `StructureDSL#sample` macro in the DSL.
|
||||||
# A corresponding `#end_group` call must be made
|
# A corresponding `#end_group` call must be made
|
||||||
# when the group being started is finished.
|
# when the group being started is finished.
|
||||||
# See `SampleExampleGroupBuilder#initialize` for the arguments
|
# See `SampleExampleGroupBuilder#create` for the arguments
|
||||||
# as arguments to this method are passed directly to it.
|
# as arguments to this method are passed directly to it.
|
||||||
def start_sample_group(*args) : Nil
|
def start_sample_group(*args) : Nil
|
||||||
group = SampleExampleGroupBuilder.new(*args)
|
group = SampleExampleGroupBuilder.create(*args)
|
||||||
push_group(group)
|
push_group(group)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,11 @@ module Spectator::DSL
|
||||||
super(what)
|
super(what)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.create(what, collection_type : C.class, name, symbol) forall C
|
||||||
|
collection = collection_type.new(sample_values).to_a
|
||||||
|
SampleExampleGroupBuilder.new(what, collection, name, symbol)
|
||||||
|
end
|
||||||
|
|
||||||
# Builds the example group.
|
# Builds the example group.
|
||||||
# A new `NestedExampleGroup` will be returned
|
# A new `NestedExampleGroup` will be returned
|
||||||
# which can have instances of `Example` and `ExampleGroup` nested in it.
|
# which can have instances of `Example` and `ExampleGroup` nested in it.
|
||||||
|
|
|
@ -558,7 +558,7 @@ module Spectator::DSL
|
||||||
# Sample groups require additional configuration.
|
# Sample groups require additional configuration.
|
||||||
::Spectator::DSL::Builder.start_sample_group(
|
::Spectator::DSL::Builder.start_sample_group(
|
||||||
{{collection.stringify}}, # String representation of the collection.
|
{{collection.stringify}}, # String representation of the collection.
|
||||||
Sample%sample.new.%to_a, # All elements in the collection.
|
Sample%sample, # All elements in the collection.
|
||||||
{{name.stringify}}, # Name for the current element.
|
{{name.stringify}}, # Name for the current element.
|
||||||
:%sample # Unique identifier for retrieving elements for the associated collection.
|
:%sample # Unique identifier for retrieving elements for the associated collection.
|
||||||
)
|
)
|
||||||
|
@ -678,7 +678,7 @@ module Spectator::DSL
|
||||||
# Sample groups require additional configuration.
|
# Sample groups require additional configuration.
|
||||||
::Spectator::DSL::Builder.start_sample_group(
|
::Spectator::DSL::Builder.start_sample_group(
|
||||||
{{collection.stringify}}, # String representation of the collection.
|
{{collection.stringify}}, # String representation of the collection.
|
||||||
Sample%sample.new.%to_a, # All elements in the collection.
|
Sample%sample, # All elements in the collection.
|
||||||
{{name.stringify}}, # Name for the current element.
|
{{name.stringify}}, # Name for the current element.
|
||||||
:%sample # Unique identifier for retrieving elements for the associated collection.
|
:%sample # Unique identifier for retrieving elements for the associated collection.
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue