diff --git a/src/spectator/dsl/tags.cr b/src/spectator/dsl/tags.cr index f2dc268..44fbf66 100644 --- a/src/spectator/dsl/tags.cr +++ b/src/spectator/dsl/tags.cr @@ -6,15 +6,15 @@ module Spectator::DSL private macro _spectator_tags(name, source, *tags, **metadata) private def self.{{name.id}} %tags = {{source.id}} - {% unless tags.empty? %} - %tags.concat({ {{tags.map(&.id.symbolize).splat}} }) + {% for k in tags %} + %tags[{{k.id.symbolize}}] = nil {% end %} {% for k, v in metadata %} %cond = begin {{v}} end if %cond - %tags.add({{k.id.symbolize}}) + %tags[{{k.id.symbolize}}] = %cond else %tags.delete({{k.id.symbolize}}) end diff --git a/src/spectator/example.cr b/src/spectator/example.cr index cc9805c..7d9fbd1 100644 --- a/src/spectator/example.cr +++ b/src/spectator/example.cr @@ -75,7 +75,8 @@ module Spectator # Note: The tags will not be merged with the parent tags. def self.pending(name : String? = nil, location : Location? = nil, group : ExampleGroup? = nil, tags = Tags.new) - new(name, location, group, tags.add(:pending)) { nil } + tags = tags.merge({:pending => nil}) { |_, v, _| v } # Add pending tag if it doesn't exist. + new(name, location, group, tags) { nil } end # Executes the test case. diff --git a/src/spectator/node.cr b/src/spectator/node.cr index d1560c8..12db776 100644 --- a/src/spectator/node.cr +++ b/src/spectator/node.cr @@ -43,7 +43,7 @@ module Spectator # Checks if the node has been marked as pending. # Pending items should be skipped during execution. def pending? - tags.includes?(:pending) + tags.has_key?(:pending) end # Constructs the full name or description of the node. diff --git a/src/spectator/tags.cr b/src/spectator/tags.cr index e7c1065..e37a473 100644 --- a/src/spectator/tags.cr +++ b/src/spectator/tags.cr @@ -1,4 +1,8 @@ module Spectator # User-defined keywords used for filtering and behavior modification. - alias Tags = Set(Symbol) + # The value of a tag is optional, but may contain useful information. + # If the value is nil, the tag exists, but has no data. + # However, when tags are given on examples and example groups, + # if the value is falsey (false or nil), then the tag should be removed from the overall collection. + alias Tags = Hash(Symbol, String?) end