mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Add support for interpolation in context names
This commit is contained in:
parent
30602663fe
commit
8c3900adcb
4 changed files with 8 additions and 2 deletions
|
@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
### Added
|
### Added
|
||||||
- Added ability to cast types using the return value from expect/should statements with a type matcher.
|
- Added ability to cast types using the return value from expect/should statements with a type matcher.
|
||||||
|
- Added support for string interpolation in context names/labels.
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Fix invalid syntax (unterminated call) when recording calls to stubs with an un-named splat.
|
- Fix invalid syntax (unterminated call) when recording calls to stubs with an un-named splat.
|
||||||
|
|
|
@ -8,7 +8,7 @@ Spectator.describe "Interpolated Label" do
|
||||||
expect(example.name).to eq("interpolates example labels")
|
expect(example.name).to eq("interpolates example labels")
|
||||||
end
|
end
|
||||||
|
|
||||||
context "within a \#{bar}" do
|
context "within a #{bar}" do
|
||||||
let(foo) { "multiple" }
|
let(foo) { "multiple" }
|
||||||
|
|
||||||
it "interpolates context labels" do |example|
|
it "interpolates context labels" do |example|
|
||||||
|
|
|
@ -4,6 +4,11 @@
|
||||||
# This type is intentionally outside the `Spectator` module.
|
# 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.
|
# The reason for this is to prevent name collision when using the DSL to define a spec.
|
||||||
abstract class SpectatorContext
|
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.
|
# Produces a dummy string to represent the context as a string.
|
||||||
# This prevents the default behavior, which normally stringifies instance variables.
|
# This prevents the default behavior, which normally stringifies instance variables.
|
||||||
# Due to the sheer amount of types Spectator can create
|
# Due to the sheer amount of types Spectator can create
|
||||||
|
|
|
@ -137,7 +137,7 @@ module Spectator::DSL
|
||||||
what.is_a?(NilLiteral) %}
|
what.is_a?(NilLiteral) %}
|
||||||
{{what}}
|
{{what}}
|
||||||
{% elsif what.is_a?(StringInterpolation) %}
|
{% elsif what.is_a?(StringInterpolation) %}
|
||||||
{% raise "String interpolation isn't supported for example group names" %}
|
{{@type.name}}.new.eval { {{what}} }
|
||||||
{% else %}
|
{% else %}
|
||||||
{{what.stringify}}
|
{{what.stringify}}
|
||||||
{% end %}
|
{% end %}
|
||||||
|
|
Loading…
Reference in a new issue