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}})
|
%source = ::Spectator::Source.new({{_source_file}}, {{_source_line}})
|
||||||
::Spectator::SpecBuilder.add_example(
|
::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,
|
%source,
|
||||||
{{@type.name}}
|
{{@type.name}}
|
||||||
) { |test| test.as({{@type.name}}).%run }
|
) { |test| test.as({{@type.name}}).%run }
|
||||||
|
@ -47,7 +47,7 @@ module Spectator
|
||||||
|
|
||||||
%source = ::Spectator::Source.new({{_source_file}}, {{_source_line}})
|
%source = ::Spectator::Source.new({{_source_file}}, {{_source_line}})
|
||||||
::Spectator::SpecBuilder.add_pending_example(
|
::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,
|
%source,
|
||||||
{{@type.name}}
|
{{@type.name}}
|
||||||
) { |test| test.as({{@type.name}}).%run }
|
) { |test| test.as({{@type.name}}).%run }
|
||||||
|
|
|
@ -5,7 +5,7 @@ module Spectator
|
||||||
macro context(what, _source_file = __FILE__, _source_line = __LINE__, &block)
|
macro context(what, _source_file = __FILE__, _source_line = __LINE__, &block)
|
||||||
class Context%context < {{@type.id}}
|
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?(".")
|
if what.starts_with?("#") || what.starts_with?(".")
|
||||||
what.id.symbolize
|
what.id.symbolize
|
||||||
else
|
else
|
||||||
|
|
|
@ -2,7 +2,7 @@ require "../mocks"
|
||||||
|
|
||||||
module Spectator::DSL
|
module Spectator::DSL
|
||||||
macro double(name = "Anonymous", **stubs, &block)
|
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}})
|
anonymous_double({{name}}, {{stubs.double_splat}})
|
||||||
{% else %}
|
{% else %}
|
||||||
{%
|
{%
|
||||||
|
@ -56,7 +56,7 @@ module Spectator::DSL
|
||||||
end
|
end
|
||||||
|
|
||||||
macro null_double(name, **stubs, &block)
|
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}})
|
anonymous_null_double({{name}}, {{stubs.double_splat}})
|
||||||
{% else %}
|
{% else %}
|
||||||
{%
|
{%
|
||||||
|
|
Loading…
Reference in a new issue