From 7f58c52e43f243d20aafe591068177767e22171e Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Sat, 17 Aug 2019 08:05:05 -0600 Subject: [PATCH] Cleanup --- src/spectator/dsl/sample_example_group_builder.cr | 8 ++++++-- src/spectator/dsl/structure_dsl.cr | 10 +++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/spectator/dsl/sample_example_group_builder.cr b/src/spectator/dsl/sample_example_group_builder.cr index 8dc3cd6..62c0746 100644 --- a/src/spectator/dsl/sample_example_group_builder.cr +++ b/src/spectator/dsl/sample_example_group_builder.cr @@ -2,6 +2,7 @@ require "./nested_example_group_builder" module Spectator::DSL # Specialized example group builder for "sample" groups. + # The type parameter `C` is the type to instantiate to create the collection. # The type parameter `T` should be the type of each element in the sample collection. # This builder creates a container group with groups inside for each item in the collection. # The hooks are only defined for the container group. @@ -9,7 +10,9 @@ module Spectator::DSL class SampleExampleGroupBuilder(C, T) < NestedExampleGroupBuilder # Creates a new group builder. # The value for *what* should be the text the user specified for the collection. - # The *collection* is the actual array of items to create examples for. + # The *collection_type* is the type to create that will produce the items. + # The *collection_builder* is a proc that takes an instance of *collection_type* + # and returns an actual array of items to create examples for. # The *name* is the variable name that the user accesses the current collection item with. # # In this code: @@ -25,7 +28,8 @@ module Spectator::DSL # The *symbol* is passed along to the sample values # so that the example code can retrieve the current item from the collection. # The symbol should be unique. - def initialize(what : String, @collection_type : C.class, @collection_builder : C -> Array(T), @name : String, @symbol : Symbol) + def initialize(what : String, @collection_type : C.class, @collection_builder : C -> Array(T), + @name : String, @symbol : Symbol) super(what) end diff --git a/src/spectator/dsl/structure_dsl.cr b/src/spectator/dsl/structure_dsl.cr index b6cd661..1957d03 100644 --- a/src/spectator/dsl/structure_dsl.cr +++ b/src/spectator/dsl/structure_dsl.cr @@ -564,11 +564,11 @@ module Spectator::DSL # Start a new example group. # Sample groups require additional configuration. ::Spectator::DSL::Builder.start_sample_group( - {{collection.stringify}}, # String representation of the collection. - Sample%sample, # All elements in the collection. - ->(s : Sample%sample) { s.%to_a }, - {{name.stringify}}, # Name for the current element. - :%sample # Unique identifier for retrieving elements for the associated collection. + {{collection.stringify}}, # String representation of the collection. + Sample%sample, # Type that can construct the elements. + ->(s : Sample%sample) { s.%to_a }, # Proc to build the array of elements in the collection. + {{name.stringify}}, # Name for the current element. + :%sample # Unique identifier for retrieving elements for the associated collection. ) # Nest the block's content in the module.