mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Initial work to pass along pre-set tags
Define pending examples and groups using this method.
This commit is contained in:
parent
de779fdf61
commit
803a09464d
2 changed files with 58 additions and 22 deletions
|
@ -8,7 +8,7 @@ module Spectator::DSL
|
||||||
# Defines a macro to generate code for an example.
|
# Defines a macro to generate code for an example.
|
||||||
# The *name* is the name given to the macro.
|
# The *name* is the name given to the macro.
|
||||||
# TODO: Mark example as pending if block is omitted.
|
# TODO: Mark example as pending if block is omitted.
|
||||||
macro define_example(name)
|
macro define_example(name, *tags, **metadata)
|
||||||
# Defines an example.
|
# Defines an example.
|
||||||
#
|
#
|
||||||
# If a block is given, it is treated as the code to test.
|
# If a block is given, it is treated as the code to test.
|
||||||
|
@ -28,6 +28,19 @@ module Spectator::DSL
|
||||||
|
|
||||||
def self.\%tags
|
def self.\%tags
|
||||||
tags = _spectator_tags
|
tags = _spectator_tags
|
||||||
|
{% if !tags.empty? %}
|
||||||
|
tags.concat({ {{tags.map(&.id.symbolize).splat}} })
|
||||||
|
{% end %}
|
||||||
|
{% for k, v in metadata %}
|
||||||
|
cond = begin
|
||||||
|
{{v}}
|
||||||
|
end
|
||||||
|
if cond
|
||||||
|
tags.add({{k.id.symbolize}})
|
||||||
|
else
|
||||||
|
tags.delete({{k.id.symbolize}})
|
||||||
|
end
|
||||||
|
{% end %}
|
||||||
\{% if !tags.empty? %}
|
\{% if !tags.empty? %}
|
||||||
tags.concat({ \{{tags.map(&.id.symbolize).splat}} })
|
tags.concat({ \{{tags.map(&.id.symbolize).splat}} })
|
||||||
\{% end %}
|
\{% end %}
|
||||||
|
@ -85,6 +98,12 @@ module Spectator::DSL
|
||||||
|
|
||||||
define_example :specify
|
define_example :specify
|
||||||
|
|
||||||
# TODO: pending, skip, and xit
|
define_example :xexample, :pending
|
||||||
|
|
||||||
|
define_example :xspecify, :pending
|
||||||
|
|
||||||
|
define_example :xit, :pending
|
||||||
|
|
||||||
|
define_example :skip, :pending
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,7 +5,7 @@ module Spectator::DSL
|
||||||
# DSL methods and macros for creating example groups.
|
# DSL methods and macros for creating example groups.
|
||||||
# This module should be included as a mix-in.
|
# This module should be included as a mix-in.
|
||||||
module Groups
|
module Groups
|
||||||
macro define_example_group(name)
|
macro define_example_group(name, *tags, **metadata)
|
||||||
# Defines a new example group.
|
# Defines a new example group.
|
||||||
# The *what* argument is a name or description of the group.
|
# The *what* argument is a name or description of the group.
|
||||||
#
|
#
|
||||||
|
@ -16,25 +16,36 @@ module Spectator::DSL
|
||||||
class Group\%group < \{{@type.id}}
|
class Group\%group < \{{@type.id}}
|
||||||
_spectator_group_subject(\{{what}})
|
_spectator_group_subject(\{{what}})
|
||||||
|
|
||||||
\{% if !tags.empty? || !metadata.empty? %}
|
def self._spectator_tags
|
||||||
def self._spectator_tags
|
tags = super
|
||||||
tags = super
|
{% if !tags.empty? %}
|
||||||
\{% if !tags.empty? %}
|
tags.concat({ {{tags.map(&.id.symbolize).splat}} })
|
||||||
tags.concat({ \{{tags.map(&.id.symbolize).splat}} })
|
{% end %}
|
||||||
\{% end %}
|
{% for k, v in metadata %}
|
||||||
\{% for k, v in metadata %}
|
cond = begin
|
||||||
cond = begin
|
{{v}}
|
||||||
\{{v}}
|
end
|
||||||
end
|
if cond
|
||||||
if cond
|
tags.add({{k.id.symbolize}})
|
||||||
tags.add(\{{k.id.symbolize}})
|
else
|
||||||
else
|
tags.delete({{k.id.symbolize}})
|
||||||
tags.delete(\{{k.id.symbolize}})
|
end
|
||||||
end
|
{% end %}
|
||||||
\{% end %}
|
\{% if !tags.empty? %}
|
||||||
tags
|
tags.concat({ \{{tags.map(&.id.symbolize).splat}} })
|
||||||
end
|
\{% end %}
|
||||||
\{% end %}
|
\{% for k, v in metadata %}
|
||||||
|
cond = begin
|
||||||
|
\{{v}}
|
||||||
|
end
|
||||||
|
if cond
|
||||||
|
tags.add(\{{k.id.symbolize}})
|
||||||
|
else
|
||||||
|
tags.delete(\{{k.id.symbolize}})
|
||||||
|
end
|
||||||
|
\{% end %}
|
||||||
|
tags
|
||||||
|
end
|
||||||
|
|
||||||
::Spectator::DSL::Builder.start_group(
|
::Spectator::DSL::Builder.start_group(
|
||||||
_spectator_group_name(\{{what}}),
|
_spectator_group_name(\{{what}}),
|
||||||
|
@ -107,6 +118,12 @@ module Spectator::DSL
|
||||||
|
|
||||||
define_example_group :context
|
define_example_group :context
|
||||||
|
|
||||||
|
define_example_group :xexample_group, :pending
|
||||||
|
|
||||||
|
define_example_group :xdescribe, :pending
|
||||||
|
|
||||||
|
define_example_group :xcontext, :pending
|
||||||
|
|
||||||
# TODO: sample, random_sample, and given
|
# TODO: sample, random_sample, and given
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue