Add methods matching RSpec for configuring include and exclude tags

This commit is contained in:
Michael Miller 2021-08-17 23:40:58 -06:00
parent c209fe7259
commit 1e82608500
No known key found for this signature in database
GPG key ID: F9A0C5C65B162436

View file

@ -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.