mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Formalize Spectator debug
This commit is contained in:
parent
f1ad476ae5
commit
cccfa8ea1d
2 changed files with 11 additions and 9 deletions
|
@ -8,6 +8,14 @@ module Spectator
|
|||
# Current version of the Spectator library.
|
||||
VERSION = {{ `shards version #{__DIR__}`.stringify.chomp }}
|
||||
|
||||
# Inserts code to produce a debug message.
|
||||
# The code will only be injected when `spectator_debug` is defined (`-Dspectator_debug`).
|
||||
macro debug_out(message)
|
||||
{% if flag?(:spectator_debug) %}
|
||||
STDERR.puts {{message}}
|
||||
{% end %}
|
||||
end
|
||||
|
||||
# Top-level describe method.
|
||||
# All specs in a file must be wrapped in this call.
|
||||
# This takes an argument and a block.
|
||||
|
|
|
@ -36,9 +36,7 @@ module Spectator
|
|||
# The newly created group is returned.
|
||||
# It shouldn't be used outside of this class until a matching `#end_group` is called.
|
||||
def start_group(name, source = nil) : ExampleGroup
|
||||
{% if flag?(:spectator_debug) %}
|
||||
puts "Start group: #{name.inspect} @ #{source}"
|
||||
{% end %}
|
||||
Spectator.debug_out("Start group: #{name.inspect} @ #{source}")
|
||||
ExampleGroup.new(name, source, current_group).tap do |group|
|
||||
@group_stack << group
|
||||
end
|
||||
|
@ -51,9 +49,7 @@ module Spectator
|
|||
# At this point, it is safe to use the group.
|
||||
# All of its examples and sub-groups have been populated.
|
||||
def end_group : ExampleGroup
|
||||
{% if flag?(:spectator_debug) %}
|
||||
puts "End group: #{current_group}"
|
||||
{% end %}
|
||||
Spectator.debug_out("End group: #{current_group}")
|
||||
raise "Can't pop root group" if root?
|
||||
|
||||
@group_stack.pop
|
||||
|
@ -78,9 +74,7 @@ module Spectator
|
|||
#
|
||||
# The newly created example is returned.
|
||||
def add_example(name, source, context, &block : Example, Context ->) : Example
|
||||
{% if flag?(:spectator_debug) %}
|
||||
puts "Add example: #{name} @ #{source}"
|
||||
{% end %}
|
||||
Spectator.debug_out("Add example: #{name} @ #{source}")
|
||||
delegate = ExampleContextDelegate.new(context, block)
|
||||
Example.new(delegate, name, source, current_group)
|
||||
# The example is added to the current group by `Example` initializer.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue