mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Indicate class double/mock in stubbed name
This commit is contained in:
parent
cecd2464de
commit
056d5892fa
3 changed files with 25 additions and 8 deletions
|
@ -130,6 +130,14 @@ module Spectator
|
||||||
{% end %}
|
{% end %}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private def self._spectator_stubbed_name : String
|
||||||
|
{% if anno = @type.annotation(StubbedName) %}
|
||||||
|
"#<Class Double " + \{{(anno[0] || :Anonymous.id).stringify}} + "\">"
|
||||||
|
{% else %}
|
||||||
|
"#<Class Double Anonymous>"
|
||||||
|
{% end %}
|
||||||
|
end
|
||||||
|
|
||||||
private def _spectator_stub_fallback(call : MethodCall, &)
|
private def _spectator_stub_fallback(call : MethodCall, &)
|
||||||
Log.trace { "Fallback for #{call} - call original" }
|
Log.trace { "Fallback for #{call} - call original" }
|
||||||
yield
|
yield
|
||||||
|
|
|
@ -63,6 +63,14 @@ module Spectator
|
||||||
\{% end %}
|
\{% end %}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private def self._spectator_stubbed_name : String
|
||||||
|
\{% if anno = @type.annotation(::Spectator::StubbedName) %}
|
||||||
|
"#<Class Mock {{mocked_type.id}} \"" + \{{(anno[0] || :Anonymous.id).stringify}} + "\">"
|
||||||
|
\{% else %}
|
||||||
|
"#<Class Mock {{mocked_type.id}}>"
|
||||||
|
\{% end %}
|
||||||
|
end
|
||||||
|
|
||||||
macro finished
|
macro finished
|
||||||
stub_type {{mocked_type.id}}
|
stub_type {{mocked_type.id}}
|
||||||
|
|
||||||
|
@ -149,6 +157,15 @@ module Spectator
|
||||||
\{% end %}
|
\{% end %}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Returns the mock's name formatted for user output.
|
||||||
|
private def self._spectator_stubbed_name : String
|
||||||
|
\{% if anno = @type.annotation(::Spectator::StubbedName) %}
|
||||||
|
"#<Class Mock {{type_name.id}} \"" + \{{(anno[0] || :Anonymous.id).stringify}} + "\">"
|
||||||
|
\{% else %}
|
||||||
|
"#<Class Mock {{type_name.id}}>"
|
||||||
|
\{% end %}
|
||||||
|
end
|
||||||
|
|
||||||
macro finished
|
macro finished
|
||||||
stub_type {{type_name.id}}
|
stub_type {{type_name.id}}
|
||||||
|
|
||||||
|
|
|
@ -54,13 +54,5 @@ module Spectator
|
||||||
def _spectator_abstract_stub_fallback(call : MethodCall, type)
|
def _spectator_abstract_stub_fallback(call : MethodCall, type)
|
||||||
_spectator_abstract_stub_fallback(call)
|
_spectator_abstract_stub_fallback(call)
|
||||||
end
|
end
|
||||||
|
|
||||||
def _spectator_stubbed_name : String
|
|
||||||
{% if anno = @type.annotation(StubbedName) %}
|
|
||||||
"#<Stubbed " + {{(anno[0] || :Anonymous.id).stringify}} + ">"
|
|
||||||
{% else %}
|
|
||||||
"#<Stubbed " + {{@type.name.stringify}} + ">"
|
|
||||||
{% end %}
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue