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.
|
||||
# The *name* is the name given to the macro.
|
||||
# TODO: Mark example as pending if block is omitted.
|
||||
macro define_example(name)
|
||||
macro define_example(name, *tags, **metadata)
|
||||
# Defines an example.
|
||||
#
|
||||
# If a block is given, it is treated as the code to test.
|
||||
|
@ -28,6 +28,19 @@ module Spectator::DSL
|
|||
|
||||
def self.\%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? %}
|
||||
tags.concat({ \{{tags.map(&.id.symbolize).splat}} })
|
||||
\{% end %}
|
||||
|
@ -85,6 +98,12 @@ module Spectator::DSL
|
|||
|
||||
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
|
||||
|
|
|
@ -5,7 +5,7 @@ module Spectator::DSL
|
|||
# DSL methods and macros for creating example groups.
|
||||
# This module should be included as a mix-in.
|
||||
module Groups
|
||||
macro define_example_group(name)
|
||||
macro define_example_group(name, *tags, **metadata)
|
||||
# Defines a new example group.
|
||||
# The *what* argument is a name or description of the group.
|
||||
#
|
||||
|
@ -16,25 +16,36 @@ module Spectator::DSL
|
|||
class Group\%group < \{{@type.id}}
|
||||
_spectator_group_subject(\{{what}})
|
||||
|
||||
\{% if !tags.empty? || !metadata.empty? %}
|
||||
def self._spectator_tags
|
||||
tags = super
|
||||
\{% 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 %}
|
||||
tags
|
||||
end
|
||||
\{% end %}
|
||||
def self._spectator_tags
|
||||
tags = super
|
||||
{% 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? %}
|
||||
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 %}
|
||||
tags
|
||||
end
|
||||
|
||||
::Spectator::DSL::Builder.start_group(
|
||||
_spectator_group_name(\{{what}}),
|
||||
|
@ -107,6 +118,12 @@ module Spectator::DSL
|
|||
|
||||
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
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue