Get contextual values working with doubles

This commit is contained in:
Michael Miller 2019-10-05 07:38:13 -06:00
parent d08ec75db7
commit 00c0553426
2 changed files with 15 additions and 2 deletions

View file

@ -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

View file

@ -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 %}