mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Allow string interpolation in some macros
Enables interpolation in example and group descriptions, as well as anonymous doubles. Addresses https://github.com/icy-arctic-fox/spectator/issues/10
This commit is contained in:
parent
4a7e0c8bd7
commit
a0af1e7cd1
3 changed files with 5 additions and 5 deletions
|
@ -20,7 +20,7 @@ module Spectator
|
|||
|
||||
%source = ::Spectator::Source.new({{_source_file}}, {{_source_line}})
|
||||
::Spectator::SpecBuilder.add_example(
|
||||
{{description.is_a?(StringLiteral) || description.is_a?(NilLiteral) ? description : description.stringify}},
|
||||
{{description.is_a?(StringLiteral) || description.is_a?(StringInterpolation) || description.is_a?(NilLiteral) ? description : description.stringify}},
|
||||
%source,
|
||||
{{@type.name}}
|
||||
) { |test| test.as({{@type.name}}).%run }
|
||||
|
@ -47,7 +47,7 @@ module Spectator
|
|||
|
||||
%source = ::Spectator::Source.new({{_source_file}}, {{_source_line}})
|
||||
::Spectator::SpecBuilder.add_pending_example(
|
||||
{{description.is_a?(StringLiteral) || description.is_a?(NilLiteral) ? description : description.stringify}},
|
||||
{{description.is_a?(StringLiteral) || description.is_a?(StringInterpolation) || description.is_a?(NilLiteral) ? description : description.stringify}},
|
||||
%source,
|
||||
{{@type.name}}
|
||||
) { |test| test.as({{@type.name}}).%run }
|
||||
|
|
|
@ -5,7 +5,7 @@ module Spectator
|
|||
macro context(what, _source_file = __FILE__, _source_line = __LINE__, &block)
|
||||
class Context%context < {{@type.id}}
|
||||
{%
|
||||
description = if what.is_a?(StringLiteral)
|
||||
description = if what.is_a?(StringLiteral) || what.is_a?(StringInterpolation)
|
||||
if what.starts_with?("#") || what.starts_with?(".")
|
||||
what.id.symbolize
|
||||
else
|
||||
|
|
|
@ -2,7 +2,7 @@ require "../mocks"
|
|||
|
||||
module Spectator::DSL
|
||||
macro double(name = "Anonymous", **stubs, &block)
|
||||
{% if name.is_a?(StringLiteral) %}
|
||||
{% if name.is_a?(StringLiteral) || name.is_a?(StringInterpolation) %}
|
||||
anonymous_double({{name}}, {{stubs.double_splat}})
|
||||
{% else %}
|
||||
{%
|
||||
|
@ -56,7 +56,7 @@ module Spectator::DSL
|
|||
end
|
||||
|
||||
macro null_double(name, **stubs, &block)
|
||||
{% if name.is_a?(StringLiteral) %}
|
||||
{% if name.is_a?(StringLiteral) || name.is_a?(StringInterpolation) %}
|
||||
anonymous_null_double({{name}}, {{stubs.double_splat}})
|
||||
{% else %}
|
||||
{%
|
||||
|
|
Loading…
Reference in a new issue