From 1e82608500aa27b8446da3ffe24d627959888f23 Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Tue, 17 Aug 2021 23:40:58 -0600 Subject: [PATCH] Add methods matching RSpec for configuring include and exclude tags --- src/spectator/config/builder.cr | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/spectator/config/builder.cr b/src/spectator/config/builder.cr index 99ce3c0..476da4d 100644 --- a/src/spectator/config/builder.cr +++ b/src/spectator/config/builder.cr @@ -3,6 +3,7 @@ require "../node_filter" require "../formatting" require "../null_node_filter" require "../run_flags" +require "../tag_node_filter" module Spectator class Config @@ -264,11 +265,23 @@ module Spectator @filters << filter end + # Specifies one or more tags to constrain running examples to. + def filter_run_including(*tags : Symbol, **values) + tags.each { |tag| @filters << TagNodeFilter.new(tag) } + values.each { |tag, value| @filters << TagNodeFilter.new(tag, value.to_s) } + end + # Adds a filter to prevent examples from running. def add_node_reject(filter : NodeFilter) @rejects << filter end + # Specifies one or more tags to exclude from running examples. + def filter_run_excluding(*tags : Symbol, **values) + tags.each { |tag| @rejects << TagNodeFilter.new(tag) } + values.each { |tag, value| @rejects << TagNodeFilter.new(tag, value.to_s) } + end + # Retrieves a filter that determines which examples can run. # If no filters were added with `#add_node_filter`, # then the returned filter will allow all examples to be run.