mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Handle changing test scope
This matches the current pattern, where a nested scope can override values from a parent scope. I think this solution is quite clever :)
This commit is contained in:
parent
6e50e54e05
commit
4b57ddab80
1 changed files with 8 additions and 4 deletions
|
@ -3,14 +3,18 @@ require "../double"
|
|||
module Spectator::DSL
|
||||
macro double(name, &block)
|
||||
{% if block.is_a?(Nop) %}
|
||||
Double{{name.id}}.new(@spectator_test_values)
|
||||
Double{{name.id}}.new(self)
|
||||
{% else %}
|
||||
class Double{{name.id}} < ::Spectator::Double
|
||||
private class Internal < {{@type.id}}
|
||||
private class Internal
|
||||
def initialize(@test : {{@type.id}})
|
||||
end
|
||||
|
||||
def initialize(test_values : ::Spectator::TestValues)
|
||||
@internal = Internal.new(test_values)
|
||||
forward_missing_to @test
|
||||
end
|
||||
|
||||
def initialize(test : {{@type.id}})
|
||||
@internal = Internal.new(test)
|
||||
end
|
||||
|
||||
{{block.body}}
|
||||
|
|
Loading…
Reference in a new issue