mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Promote Tags to the Spectator namespace
This commit is contained in:
parent
db877da984
commit
c5246e1cd3
5 changed files with 14 additions and 8 deletions
|
@ -5,6 +5,7 @@ require "./pending_result"
|
||||||
require "./result"
|
require "./result"
|
||||||
require "./source"
|
require "./source"
|
||||||
require "./spec/node"
|
require "./spec/node"
|
||||||
|
require "./tags"
|
||||||
|
|
||||||
module Spectator
|
module Spectator
|
||||||
# Standard example that runs a test case.
|
# Standard example that runs a test case.
|
||||||
|
@ -28,7 +29,7 @@ module Spectator
|
||||||
# A set of *tags* can be used for filtering and modifying example behavior.
|
# A set of *tags* can be used for filtering and modifying example behavior.
|
||||||
def initialize(@context : Context, @entrypoint : self ->,
|
def initialize(@context : Context, @entrypoint : self ->,
|
||||||
name : String? = nil, source : Source? = nil,
|
name : String? = nil, source : Source? = nil,
|
||||||
group : ExampleGroup? = nil, tags = Spec::Node::Tags.new)
|
group : ExampleGroup? = nil, tags = Tags.new)
|
||||||
super(name, source, group, tags)
|
super(name, source, group, tags)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -41,7 +42,7 @@ module Spectator
|
||||||
# The example will be assigned to *group* if it is provided.
|
# The example will be assigned to *group* if it is provided.
|
||||||
# A set of *tags* can be used for filtering and modifying example behavior.
|
# A set of *tags* can be used for filtering and modifying example behavior.
|
||||||
def initialize(name : String? = nil, source : Source? = nil, group : ExampleGroup? = nil,
|
def initialize(name : String? = nil, source : Source? = nil, group : ExampleGroup? = nil,
|
||||||
tags = Spec::Node::Tags.new, &block : self ->)
|
tags = Tags.new, &block : self ->)
|
||||||
super(name, source, group, tags)
|
super(name, source, group, tags)
|
||||||
@context = NullContext.new
|
@context = NullContext.new
|
||||||
@entrypoint = block
|
@entrypoint = block
|
||||||
|
|
|
@ -4,6 +4,7 @@ require "../example"
|
||||||
require "../example_context_method"
|
require "../example_context_method"
|
||||||
require "../example_group"
|
require "../example_group"
|
||||||
require "../spec"
|
require "../spec"
|
||||||
|
require "../tags"
|
||||||
|
|
||||||
module Spectator
|
module Spectator
|
||||||
class Spec
|
class Spec
|
||||||
|
@ -58,7 +59,7 @@ module Spectator
|
||||||
#
|
#
|
||||||
# The newly created group is returned.
|
# The newly created group is returned.
|
||||||
# It shouldn't be used outside of this class until a matching `#end_group` is called.
|
# It shouldn't be used outside of this class until a matching `#end_group` is called.
|
||||||
def start_group(name, source = nil, tags = Spec::Node::Tags.new) : ExampleGroup
|
def start_group(name, source = nil, tags = Tags.new) : ExampleGroup
|
||||||
Log.trace { "Start group: #{name.inspect} @ #{source}; tags: #{tags}" }
|
Log.trace { "Start group: #{name.inspect} @ #{source}; tags: #{tags}" }
|
||||||
ExampleGroup.new(name, source, current_group, tags).tap do |group|
|
ExampleGroup.new(name, source, current_group, tags).tap do |group|
|
||||||
@group_stack << group
|
@group_stack << group
|
||||||
|
@ -99,7 +100,7 @@ module Spectator
|
||||||
# It is expected that the test code runs when the block is called.
|
# It is expected that the test code runs when the block is called.
|
||||||
#
|
#
|
||||||
# The newly created example is returned.
|
# The newly created example is returned.
|
||||||
def add_example(name, source, context, tags = Spec::Node::Tags.new, &block : Example -> _) : Example
|
def add_example(name, source, context, tags = Tags.new, &block : Example -> _) : Example
|
||||||
Log.trace { "Add example: #{name} @ #{source}; tags: #{tags}" }
|
Log.trace { "Add example: #{name} @ #{source}; tags: #{tags}" }
|
||||||
Example.new(context, block, name, source, current_group, tags)
|
Example.new(context, block, name, source, current_group, tags)
|
||||||
# The example is added to the current group by `Example` initializer.
|
# The example is added to the current group by `Example` initializer.
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
require "../label"
|
require "../label"
|
||||||
require "../source"
|
require "../source"
|
||||||
|
require "../tags"
|
||||||
|
|
||||||
module Spectator
|
module Spectator
|
||||||
class Spec
|
class Spec
|
||||||
|
@ -7,9 +8,6 @@ module Spectator
|
||||||
# This is commonly an `Example` or `ExampleGroup`,
|
# This is commonly an `Example` or `ExampleGroup`,
|
||||||
# but can be anything that should be iterated over when running the spec.
|
# but can be anything that should be iterated over when running the spec.
|
||||||
abstract class Node
|
abstract class Node
|
||||||
# User-defined keywords used for filtering and behavior modification.
|
|
||||||
alias Tags = Set(Symbol)
|
|
||||||
|
|
||||||
# Location of the node in source code.
|
# Location of the node in source code.
|
||||||
getter! source : Source
|
getter! source : Source
|
||||||
|
|
||||||
|
|
4
src/spectator/tags.cr
Normal file
4
src/spectator/tags.cr
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
module Spectator
|
||||||
|
# User-defined keywords used for filtering and behavior modification.
|
||||||
|
alias Tags = Set(Symbol)
|
||||||
|
end
|
|
@ -1,5 +1,7 @@
|
||||||
require "./context"
|
require "./context"
|
||||||
require "./dsl"
|
require "./dsl"
|
||||||
|
require "./lazy_wrapper"
|
||||||
|
require "./tags"
|
||||||
|
|
||||||
# Class used as the base for all specs using the DSL.
|
# Class used as the base for all specs using the DSL.
|
||||||
# It adds methods and macros necessary to use the DSL from the spec.
|
# It adds methods and macros necessary to use the DSL from the spec.
|
||||||
|
@ -31,6 +33,6 @@ class SpectatorTestContext < SpectatorContext
|
||||||
# Initial tags for tests.
|
# Initial tags for tests.
|
||||||
# This method should be overridden by example groups and examples.
|
# This method should be overridden by example groups and examples.
|
||||||
def self._spectator_tags
|
def self._spectator_tags
|
||||||
::Spectator::Example::Tags.new
|
::Spectator::Tags.new
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue