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
|
||||
# Standard example that runs a test case.
|
||||
class Example < Spec::Node
|
||||
# User-defined keywords used for filtering and behavior modification.
|
||||
alias Tags = Set(String)
|
||||
|
||||
# Currently running example.
|
||||
class_getter! current : Example
|
||||
|
||||
|
@ -21,9 +18,6 @@ module Spectator
|
|||
# Retrieves the result of the last time the example ran.
|
||||
getter result : Result = PendingResult.new
|
||||
|
||||
# User-defined keywords used for filtering and behavior modification.
|
||||
getter tags : Set(String)
|
||||
|
||||
# Creates the example.
|
||||
# An instance to run the test code in is given by *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.
|
||||
# The *source* tracks where the example exists in source code.
|
||||
# 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 ->,
|
||||
name : String? = nil, source : Source? = nil, group : ExampleGroup? = nil, @tags = Tags.new)
|
||||
super(name, source, group)
|
||||
name : String? = nil, source : Source? = nil,
|
||||
group : ExampleGroup? = nil, tags = Spec::Node::Tags.new)
|
||||
super(name, source, group, tags)
|
||||
end
|
||||
|
||||
# Creates a dynamic example.
|
||||
|
@ -43,9 +39,10 @@ module Spectator
|
|||
# It can be a `Symbol` to describe a type.
|
||||
# The *source* tracks where the example exists in source code.
|
||||
# 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,
|
||||
@tags = Tags.new, &block : self ->)
|
||||
super(name, source, group)
|
||||
tags = Spec::Node::Tags.new, &block : self ->)
|
||||
super(name, source, group, tags)
|
||||
@context = NullContext.new
|
||||
@entrypoint = block
|
||||
end
|
||||
|
|
|
@ -7,6 +7,9 @@ module Spectator
|
|||
# This is commonly an `Example` or `ExampleGroup`,
|
||||
# but can be anything that should be iterated over when running the spec.
|
||||
abstract class Node
|
||||
# User-defined keywords used for filtering and behavior modification.
|
||||
alias Tags = Set(String)
|
||||
|
||||
# Location of the node in source code.
|
||||
getter! source : Source
|
||||
|
||||
|
@ -29,6 +32,9 @@ module Spectator
|
|||
# Group the node belongs to.
|
||||
getter! group : ExampleGroup
|
||||
|
||||
# User-defined keywords used for filtering and behavior modification.
|
||||
getter tags : Tags
|
||||
|
||||
# Assigns the node to the specified *group*.
|
||||
# This is an internal method and should only be called from `ExampleGroup`.
|
||||
# `ExampleGroup` manages the association of nodes to groups.
|
||||
|
@ -39,7 +45,9 @@ module Spectator
|
|||
# It can be a `Symbol` to describe a type.
|
||||
# The *source* tracks where the node exists in source code.
|
||||
# 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.
|
||||
group << self if group
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue