Allow passing default value stubs to mock initialization

This commit is contained in:
Michael Miller 2022-06-01 22:04:18 -06:00
parent 225553127d
commit 3f4216a271
No known key found for this signature in database
GPG key ID: 32B47AE8F388A1FF
2 changed files with 28 additions and 1 deletions

View file

@ -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 %}