Don't embed mock info in type

This can cause problems. Need to use a registry approach.
This commit is contained in:
Michael Miller 2019-11-09 09:03:07 -07:00
parent 875333cffe
commit 8c2f8d973b

View file

@ -18,25 +18,18 @@ module Spectator::DSL
end end
macro mock(name, &block) macro mock(name, &block)
{% if block.is_a?(Nop) %} {% resolved = name.resolve
{{name}}.new.tap do |%inst| type = if resolved < Reference
%inst.spectator_test = self :class
end elsif resolved < Value
{% else %} :struct
{% resolved = name.resolve else
type = if resolved < Reference :module
:class end %}
elsif resolved < Value {% begin %}
:struct
else
:module
end %}
{{type.id}} ::{{resolved.id}} {{type.id}} ::{{resolved.id}}
include ::Spectator::Mocks::Stubs include ::Spectator::Mocks::Stubs
@spectator_stubs = Deque(::Spectator::Mocks::MethodStub).new
@spectator_stub_calls = Deque(::Spectator::Mocks::MethodCall).new
{{block.body}} {{block.body}}
end end
{% end %} {% end %}