mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Get contextual values working with doubles
This commit is contained in:
parent
d08ec75db7
commit
00c0553426
2 changed files with 15 additions and 2 deletions
|
@ -1,9 +1,15 @@
|
|||
module Spectator
|
||||
abstract class Double
|
||||
macro stub(definition)
|
||||
def {{definition.name.id}}
|
||||
@internal.{{definition.name.id}}
|
||||
end
|
||||
|
||||
class Internal
|
||||
def {{definition.name.id}}
|
||||
{{definition.block.body}}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,9 +3,16 @@ require "../double"
|
|||
module Spectator::DSL
|
||||
macro double(name, &block)
|
||||
{% if block.is_a?(Nop) %}
|
||||
Double{{name.id}}.new
|
||||
Double{{name.id}}.new(@spectator_test_values)
|
||||
{% else %}
|
||||
class Double{{name.id}} < ::Spectator::Double
|
||||
class Internal < {{@type.id}}
|
||||
end
|
||||
|
||||
def initialize(test_values : ::Spectator::TestValues)
|
||||
@internal = Internal.new(test_values)
|
||||
end
|
||||
|
||||
{{block.body}}
|
||||
end
|
||||
{% end %}
|
||||
|
|
Loading…
Reference in a new issue