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
1 changed files with 9 additions and 16 deletions

View File

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