mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Use standard log utility
This commit is contained in:
parent
e6d78345c4
commit
9c1fd6fb5a
3 changed files with 12 additions and 23 deletions
|
@ -28,7 +28,7 @@ module Spectator
|
|||
# Returns the result of the execution.
|
||||
# The result will also be stored in `#result`.
|
||||
def run : Result
|
||||
Spectator.debug("Running example #{self}")
|
||||
Log.debug { "Running example #{self}" }
|
||||
@delegate.call(self)
|
||||
raise NotImplementedError.new("#run")
|
||||
end
|
||||
|
|
|
@ -8,6 +8,8 @@ module Spectator
|
|||
# A stack is used to track the current example group.
|
||||
# Adding an example or group will nest it under the group at the top of the stack.
|
||||
class SpecBuilder
|
||||
Log = ::Spectator::Log.for(self)
|
||||
|
||||
# Stack tracking the current group.
|
||||
# The bottom of the stack (first element) is the root group.
|
||||
# The root group should never be removed.
|
||||
|
@ -36,7 +38,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
|
||||
Spectator.debug("Start group: #{name.inspect} @ #{source}")
|
||||
Log.trace { "Start group: #{name.inspect} @ #{source}" }
|
||||
ExampleGroup.new(name, source, current_group).tap do |group|
|
||||
@group_stack << group
|
||||
end
|
||||
|
@ -49,7 +51,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
|
||||
Spectator.debug("End group: #{current_group}")
|
||||
Log.trace { "End group: #{current_group}" }
|
||||
raise "Can't pop root group" if root?
|
||||
|
||||
@group_stack.pop
|
||||
|
@ -74,7 +76,7 @@ module Spectator
|
|||
#
|
||||
# The newly created example is returned.
|
||||
def add_example(name, source, context, &block : Example, Context ->) : Example
|
||||
Spectator.debug("Add example: #{name} @ #{source}")
|
||||
Log.trace { "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