mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Use tap to modify new mock
Without this, mocked structs were not getting their stubs applied. An unintended side-effect is the tap shows up in recorded calls. This seems to be harmless, but might need to be revisited.
This commit is contained in:
parent
0e556c3d55
commit
df5a4fa77c
1 changed files with 1 additions and 3 deletions
|
@ -294,14 +294,12 @@ module Spectator::DSL
|
|||
found_tuple = found_tuples.last %}
|
||||
|
||||
{% if found_tuple %}
|
||||
begin
|
||||
%mock = {{found_tuple[2].id}}.new
|
||||
{{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 %}
|
||||
::Spectator::Harness.current?.try(&.cleanup { %mock._spectator_reset })
|
||||
%mock
|
||||
end
|
||||
{% else %}
|
||||
{% raise "Type `#{type.id}` must be previously mocked before attempting to instantiate." %}
|
||||
|
|
Loading…
Reference in a new issue