mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Allow passing default value stubs to mock initialization
This commit is contained in:
parent
225553127d
commit
3f4216a271
2 changed files with 28 additions and 1 deletions
|
@ -178,7 +178,12 @@ module Spectator::DSL
|
|||
found_tuple = found_tuples.last %}
|
||||
|
||||
{% if found_tuple %}
|
||||
{{found_tuple[2].id}}.new({{**value_methods}})
|
||||
{{found_tuple[2].id}}.new.tap do |mock|
|
||||
{% for key, value in value_methods %}
|
||||
%stub{key} = ::Spectator::ValueStub.new({{key.id.symbolize}}, {{value}})
|
||||
mock._spectator_define_stub(%stub{key})
|
||||
{% end %}
|
||||
end
|
||||
{% else %}
|
||||
{% raise "Type `#{type.id}` must be previously mocked before attempting to instantiate." %}
|
||||
{% end %}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue