def tests(description, tags = [], &block)
return self if Thread.main[:exit] || Thread.current[:reload]
tags = [*tags]
@tag_stack.push(tags)
@befores.push([])
@afters.push([])
@description = nil
@inline = false
description ||= 'Shindo.tests'
description = "[bold]#{description}[normal]"
unless tags.empty?
description << " (#{tags.join(', ')})"
end
@description_stack.push(description)
if (@if_tagged.empty? || !(@if_tagged & @tag_stack.flatten).empty?) &&
(@unless_tagged.empty? || (@unless_tagged & @tag_stack.flatten).empty?)
if block_given?
begin
display_description(description)
indent = Thread.current[:formatador].instance_variable_get(:@indent)
Thread.current[:formatador].instance_variable_set(:@indent, indent + 1)
instance_eval(&block)
rescue Shindo::Pending
display_pending(description)
rescue => error
display_error(error)
ensure
indent = Thread.current[:formatador].instance_variable_get(:@indent)
Thread.current[:formatador].instance_variable_set(:@indent, indent - 1)
end
else
@inline = true
display_description(description)
end
else
display_description("[light_black]#{description}[/]")
end
@description_stack.pop
@afters.pop
@befores.pop
@tag_stack.pop
Thread.exit if Thread.main[:exit] || Thread.current[:reload]
self
end