Add support for interpolation in context names

This commit is contained in:
Michael Miller 2022-12-20 20:32:40 -07:00
parent 30602663fe
commit 8c3900adcb
No known key found for this signature in database
GPG key ID: AC78B32D30CE34A2
4 changed files with 8 additions and 2 deletions

View file

@ -4,6 +4,11 @@
# This type is intentionally outside the `Spectator` module.
# The reason for this is to prevent name collision when using the DSL to define a spec.
abstract class SpectatorContext
# Evaluates the contents of a block within the scope of the context.
def eval
with self yield
end
# Produces a dummy string to represent the context as a string.
# This prevents the default behavior, which normally stringifies instance variables.
# Due to the sheer amount of types Spectator can create

View file

@ -137,7 +137,7 @@ module Spectator::DSL
what.is_a?(NilLiteral) %}
{{what}}
{% elsif what.is_a?(StringInterpolation) %}
{% raise "String interpolation isn't supported for example group names" %}
{{@type.name}}.new.eval { {{what}} }
{% else %}
{{what.stringify}}
{% end %}