mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Fix clearing stubs for mocks
Prevent reverting initial defaults set by mock macro.
This commit is contained in:
parent
a39b27387c
commit
4f0e2f6e46
1 changed files with 15 additions and 5 deletions
|
@ -14,13 +14,19 @@ module Spectator
|
|||
include ::Spectator::Mocked
|
||||
|
||||
{% begin %}
|
||||
private getter _spectator_stubs = [
|
||||
private getter(_spectator_stubs) do
|
||||
[
|
||||
{% for key, value in value_methods %}
|
||||
::Spectator::ValueStub.new({{key.id.symbolize}}, {{value}}),
|
||||
{% end %}
|
||||
] of ::Spectator::Stub
|
||||
end
|
||||
{% end %}
|
||||
|
||||
def _spectator_clear_stubs : Nil
|
||||
@_spectator_stubs = nil
|
||||
end
|
||||
|
||||
# Returns the mock's name formatted for user output.
|
||||
private def _spectator_stubbed_name : String
|
||||
\{% if anno = @type.annotation(::Spectator::StubbedName) %}
|
||||
|
@ -73,6 +79,10 @@ module Spectator
|
|||
end
|
||||
end
|
||||
|
||||
def _spectator_clear_stubs : Nil
|
||||
@@_spectator_mock_registry.delete(self)
|
||||
end
|
||||
|
||||
# Returns the mock's name formatted for user output.
|
||||
private def _spectator_stubbed_name : String
|
||||
\{% if anno = @type.annotation(::Spectator::StubbedName) %}
|
||||
|
|
Loading…
Reference in a new issue