mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Move tags to node level
This commit is contained in:
parent
8cf498c9e9
commit
71a497b148
2 changed files with 16 additions and 11 deletions
|
@ -9,9 +9,6 @@ require "./spec/node"
|
||||||
module Spectator
|
module Spectator
|
||||||
# Standard example that runs a test case.
|
# Standard example that runs a test case.
|
||||||
class Example < Spec::Node
|
class Example < Spec::Node
|
||||||
# User-defined keywords used for filtering and behavior modification.
|
|
||||||
alias Tags = Set(String)
|
|
||||||
|
|
||||||
# Currently running example.
|
# Currently running example.
|
||||||
class_getter! current : Example
|
class_getter! current : Example
|
||||||
|
|
||||||
|
@ -21,9 +18,6 @@ module Spectator
|
||||||
# Retrieves the result of the last time the example ran.
|
# Retrieves the result of the last time the example ran.
|
||||||
getter result : Result = PendingResult.new
|
getter result : Result = PendingResult.new
|
||||||
|
|
||||||
# User-defined keywords used for filtering and behavior modification.
|
|
||||||
getter tags : Set(String)
|
|
||||||
|
|
||||||
# Creates the example.
|
# Creates the example.
|
||||||
# An instance to run the test code in is given by *context*.
|
# An instance to run the test code in is given by *context*.
|
||||||
# The *entrypoint* defines the test code (typically inside *context*).
|
# The *entrypoint* defines the test code (typically inside *context*).
|
||||||
|
@ -31,9 +25,11 @@ module Spectator
|
||||||
# It can be a `Symbol` to describe a type.
|
# It can be a `Symbol` to describe a type.
|
||||||
# The *source* tracks where the example exists in source code.
|
# The *source* tracks where the example exists in source code.
|
||||||
# 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.
|
||||||
def initialize(@context : Context, @entrypoint : self ->,
|
def initialize(@context : Context, @entrypoint : self ->,
|
||||||
name : String? = nil, source : Source? = nil, group : ExampleGroup? = nil, @tags = Tags.new)
|
name : String? = nil, source : Source? = nil,
|
||||||
super(name, source, group)
|
group : ExampleGroup? = nil, tags = Spec::Node::Tags.new)
|
||||||
|
super(name, source, group, tags)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Creates a dynamic example.
|
# Creates a dynamic example.
|
||||||
|
@ -43,9 +39,10 @@ module Spectator
|
||||||
# It can be a `Symbol` to describe a type.
|
# It can be a `Symbol` to describe a type.
|
||||||
# The *source* tracks where the example exists in source code.
|
# The *source* tracks where the example exists in source code.
|
||||||
# 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.
|
||||||
def initialize(name : String? = nil, source : Source? = nil, group : ExampleGroup? = nil,
|
def initialize(name : String? = nil, source : Source? = nil, group : ExampleGroup? = nil,
|
||||||
@tags = Tags.new, &block : self ->)
|
tags = Spec::Node::Tags.new, &block : self ->)
|
||||||
super(name, source, group)
|
super(name, source, group, tags)
|
||||||
@context = NullContext.new
|
@context = NullContext.new
|
||||||
@entrypoint = block
|
@entrypoint = block
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,6 +7,9 @@ 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(String)
|
||||||
|
|
||||||
# Location of the node in source code.
|
# Location of the node in source code.
|
||||||
getter! source : Source
|
getter! source : Source
|
||||||
|
|
||||||
|
@ -29,6 +32,9 @@ module Spectator
|
||||||
# Group the node belongs to.
|
# Group the node belongs to.
|
||||||
getter! group : ExampleGroup
|
getter! group : ExampleGroup
|
||||||
|
|
||||||
|
# User-defined keywords used for filtering and behavior modification.
|
||||||
|
getter tags : Tags
|
||||||
|
|
||||||
# Assigns the node to the specified *group*.
|
# Assigns the node to the specified *group*.
|
||||||
# This is an internal method and should only be called from `ExampleGroup`.
|
# This is an internal method and should only be called from `ExampleGroup`.
|
||||||
# `ExampleGroup` manages the association of nodes to groups.
|
# `ExampleGroup` manages the association of nodes to groups.
|
||||||
|
@ -39,7 +45,9 @@ module Spectator
|
||||||
# It can be a `Symbol` to describe a type.
|
# It can be a `Symbol` to describe a type.
|
||||||
# The *source* tracks where the node exists in source code.
|
# The *source* tracks where the node exists in source code.
|
||||||
# The node will be assigned to *group* if it is provided.
|
# The node will be assigned to *group* if it is provided.
|
||||||
def initialize(@name : Label = nil, @source : Source? = nil, group : ExampleGroup? = nil)
|
# A set of *tags* can be used for filtering and modifying example behavior.
|
||||||
|
def initialize(@name : Label = nil, @source : Source? = nil,
|
||||||
|
group : ExampleGroup? = nil, @tags : Tags = Tags.new)
|
||||||
# Ensure group is linked.
|
# Ensure group is linked.
|
||||||
group << self if group
|
group << self if group
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue