Playing around with mocking and type restrictions

This commit is contained in:
Michael Miller 2020-02-23 12:23:10 -07:00
parent 86729c6745
commit b44dee5331

View file

@ -111,12 +111,29 @@ module Spectator::DSL
else
:module
end %}
{% if block %}
{% begin %}
{{type.id}} ::{{resolved.id}}
include ::Spectator::Mocks::Stubs
{{block.body}}
end
{% if type == :class %}
{{type.id}} Mock{{resolved.id}} < ::{{resolved.id}}
end
{% elsif type == :module %}
class Mock{{resolved.id}}
include ::{{resolved.id}}
end
{% end %}
{% end %}
{% else %}
{% if type == :struct %}
{% raise "Cannot use mock(#{resolved.id}) to create a struct" %}
{% else %}
Mock{{resolved.id}}.new
{% end %}
{% end %}
end