diff --git a/src/spectator/dsl/examples.cr b/src/spectator/dsl/examples.cr index b711502..4798af0 100644 --- a/src/spectator/dsl/examples.cr +++ b/src/spectator/dsl/examples.cr @@ -26,8 +26,8 @@ module Spectator::DSL \{% raise "A description or block must be provided. Cannot use '{{name.id}}' alone." unless what || block %} \{% raise "Block argument count '{{name.id}}' hook must be 0..1" if block.args.size > 1 %} - _spectator_tags_method(%tags, :_spectator_tags, {{tags.splat(",")}} {{metadata.double_splat}}) - _spectator_tags_method(\%tags, %tags, \{{tags.splat(",")}} \{{metadata.double_splat}}) + _spectator_tags(%tags, :tags, {{tags.splat(",")}} {{metadata.double_splat}}) + _spectator_tags(\%tags, %tags, \{{tags.splat(",")}} \{{metadata.double_splat}}) def \%test(\{{block.args.splat}}) : Nil \{{block.body}} @@ -67,23 +67,23 @@ module Spectator::DSL # Defines a class method named *name* that combines tags # returned by *source* with *tags* and *metadata*. # Any falsey items from *metadata* are removed. - private macro _spectator_tags_method(name, source, *tags, **metadata) + private macro _spectator_tags(name, source, *tags, **metadata) def self.{{name.id}} - tags = {{source.id}} + %tags = {{source.id}} {% unless tags.empty? %} - tags.concat({ {{tags.map(&.id.symbolize).splat}} }) + %tags.concat({ {{tags.map(&.id.symbolize).splat}} }) {% end %} {% for k, v in metadata %} - cond = begin + %cond = begin {{v}} end - if cond - tags.add({{k.id.symbolize}}) + if %cond + %tags.add({{k.id.symbolize}}) else - tags.delete({{k.id.symbolize}}) + %tags.delete({{k.id.symbolize}}) end {% end %} - tags + %tags end end diff --git a/src/spectator/dsl/groups.cr b/src/spectator/dsl/groups.cr index a570cb9..6f0aef6 100644 --- a/src/spectator/dsl/groups.cr +++ b/src/spectator/dsl/groups.cr @@ -16,13 +16,13 @@ module Spectator::DSL class Group\%group < \{{@type.id}} _spectator_group_subject(\{{what}}) - _spectator_tags_method(:_spectator_tags, :super, {{tags.splat(", ")}} {{metadata.double_splat}}) - _spectator_tags_method(:_spectator_tags, :previous_def, \{{tags.splat(", ")}} \{{metadata.double_splat}}) + _spectator_tags_method(:tags, :super, {{tags.splat(", ")}} {{metadata.double_splat}}) + _spectator_tags_method(:tags, :previous_def, \{{tags.splat(", ")}} \{{metadata.double_splat}}) ::Spectator::DSL::Builder.start_group( _spectator_group_name(\{{what}}), ::Spectator::Source.new(\{{block.filename}}, \{{block.line_number}}), - _spectator_tags + tags ) \{{block.body}} @@ -89,21 +89,21 @@ module Spectator::DSL # Any falsey items from *metadata* are removed. private macro _spectator_tags_method(name, source, *tags, **metadata) def self.{{name.id}} - tags = {{source.id}} + %tags = {{source.id}} {% unless tags.empty? %} - tags.concat({ {{tags.map(&.id.symbolize).splat}} }) + %tags.concat({ {{tags.map(&.id.symbolize).splat}} }) {% end %} {% for k, v in metadata %} - cond = begin + %cond = begin {{v}} end - if cond - tags.add({{k.id.symbolize}}) + if %cond + %tags.add({{k.id.symbolize}}) else - tags.delete({{k.id.symbolize}}) + %tags.delete({{k.id.symbolize}}) end {% end %} - tags + %tags end end diff --git a/src/spectator/test_context.cr b/src/spectator/test_context.cr index 8186daa..a4a3156 100644 --- a/src/spectator/test_context.cr +++ b/src/spectator/test_context.cr @@ -32,7 +32,7 @@ class SpectatorTestContext < SpectatorContext # Initial tags for tests. # This method should be overridden by example groups and examples. - def self._spectator_tags + def self.tags ::Spectator::Tags.new end end