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

@ -2,7 +2,13 @@ module Spectator
abstract class Double abstract class Double
macro stub(definition) macro stub(definition)
def {{definition.name.id}} def {{definition.name.id}}
{{definition.block.body}} @internal.{{definition.name.id}}
end
class Internal
def {{definition.name.id}}
{{definition.block.body}}
end
end end
end end
end end

View file

@ -3,9 +3,16 @@ require "../double"
module Spectator::DSL module Spectator::DSL
macro double(name, &block) macro double(name, &block)
{% if block.is_a?(Nop) %} {% if block.is_a?(Nop) %}
Double{{name.id}}.new Double{{name.id}}.new(@spectator_test_values)
{% else %} {% else %}
class Double{{name.id}} < ::Spectator::Double 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}} {{block.body}}
end end
{% end %} {% end %}