mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Playing around with mocking and type restrictions
This commit is contained in:
parent
86729c6745
commit
b44dee5331
1 changed files with 22 additions and 5 deletions
|
@ -111,12 +111,29 @@ module Spectator::DSL
|
||||||
else
|
else
|
||||||
:module
|
:module
|
||||||
end %}
|
end %}
|
||||||
|
{% if block %}
|
||||||
{% begin %}
|
{% begin %}
|
||||||
{{type.id}} ::{{resolved.id}}
|
{{type.id}} ::{{resolved.id}}
|
||||||
include ::Spectator::Mocks::Stubs
|
include ::Spectator::Mocks::Stubs
|
||||||
|
|
||||||
{{block.body}}
|
{{block.body}}
|
||||||
end
|
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 %}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue