mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Cleanup example description handling
This commit is contained in:
parent
1d359efcb0
commit
b8ba38152e
1 changed files with 15 additions and 1 deletions
|
@ -10,13 +10,27 @@ module Spectator::DSL
|
||||||
end
|
end
|
||||||
|
|
||||||
::Spectator::DSL::Builder.add_example(
|
::Spectator::DSL::Builder.add_example(
|
||||||
\{{what.is_a?(StringLiteral) || what.is_a?(StringInterpolation) || what.is_a?(NilLiteral) ? what : what.stringify}},
|
_spectator_example_name(\{{what}}),
|
||||||
::Spectator::Source.new(\{{block.filename}}, \{{block.line_number}}),
|
::Spectator::Source.new(\{{block.filename}}, \{{block.line_number}}),
|
||||||
\{{@type.name}}.new
|
\{{@type.name}}.new
|
||||||
) { |example, context| context.as(\{{@type.name}}).%test }
|
) { |example, context| context.as(\{{@type.name}}).%test }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Inserts the correct representation of a example's name.
|
||||||
|
# If *what* is a string, then it is dropped in as-is.
|
||||||
|
# For anything else, it is stringified.
|
||||||
|
# This is intended to be used to convert a description from the spec DSL to `ExampleNode#name`.
|
||||||
|
private macro _spectator_example_name(what)
|
||||||
|
{% if what.is_a?(StringLiteral) ||
|
||||||
|
what.is_a?(StringInterpolation) ||
|
||||||
|
what.is_a?(NilLiteral) %}
|
||||||
|
{{what}}
|
||||||
|
{% else %}
|
||||||
|
{{what.stringify}}
|
||||||
|
{% end %}
|
||||||
|
end
|
||||||
|
|
||||||
define_example :example
|
define_example :example
|
||||||
|
|
||||||
define_example :it
|
define_example :it
|
||||||
|
|
Loading…
Reference in a new issue