mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Bit of method cleanup
This commit is contained in:
parent
332ab1cebc
commit
dc74a741cf
3 changed files with 4 additions and 3 deletions
|
@ -73,6 +73,7 @@ module Spectator
|
||||||
stub
|
stub
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Returns the double's name formatted for user output.
|
||||||
private def _spectator_stubbed_name : String
|
private def _spectator_stubbed_name : String
|
||||||
{% if anno = @type.annotation(StubbedName) %}
|
{% if anno = @type.annotation(StubbedName) %}
|
||||||
"#<Double " + {{(anno[0] || :Anonymous.id).stringify}} + ">"
|
"#<Double " + {{(anno[0] || :Anonymous.id).stringify}} + ">"
|
||||||
|
|
|
@ -73,6 +73,7 @@ module Spectator
|
||||||
stub
|
stub
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Returns the double's name formatted for user output.
|
||||||
private def _spectator_stubbed_name : String
|
private def _spectator_stubbed_name : String
|
||||||
{% if anno = @type.annotation(StubbedName) %}
|
{% if anno = @type.annotation(StubbedName) %}
|
||||||
"#<NullDouble " + {{(anno[0] || :Anonymous.id).stringify}} + ">"
|
"#<NullDouble " + {{(anno[0] || :Anonymous.id).stringify}} + ">"
|
||||||
|
|
|
@ -16,9 +16,6 @@ module Spectator
|
||||||
# or nil if no stubs satisfy it.
|
# or nil if no stubs satisfy it.
|
||||||
abstract def _spectator_find_stub(call : MethodCall) : Stub?
|
abstract def _spectator_find_stub(call : MethodCall) : Stub?
|
||||||
|
|
||||||
# Utility returning the mock or double's name as a string.
|
|
||||||
abstract def _spectator_stubbed_name : String
|
|
||||||
|
|
||||||
# Method called when a stub isn't found.
|
# Method called when a stub isn't found.
|
||||||
#
|
#
|
||||||
# The received message is captured in *call*.
|
# The received message is captured in *call*.
|
||||||
|
@ -80,6 +77,7 @@ module Spectator
|
||||||
# ```
|
# ```
|
||||||
#
|
#
|
||||||
# Stubbed methods will call `#_spectator_find_stub` with the method call information.
|
# Stubbed methods will call `#_spectator_find_stub` with the method call information.
|
||||||
|
# If no stub is found, then `#_spectator_stub_fallback` or `#_spectator_abstract_stub_fallback` is called.
|
||||||
private macro stub(method)
|
private macro stub(method)
|
||||||
{% raise "Cannot define a stub inside a method" if @def %}
|
{% raise "Cannot define a stub inside a method" if @def %}
|
||||||
{% raise "stub requires a method definition" if !method.is_a?(Def) %}
|
{% raise "stub requires a method definition" if !method.is_a?(Def) %}
|
||||||
|
@ -148,6 +146,7 @@ module Spectator
|
||||||
# ```
|
# ```
|
||||||
#
|
#
|
||||||
# Stubbed methods will call `#_spectator_find_stub` with the method call information.
|
# Stubbed methods will call `#_spectator_find_stub` with the method call information.
|
||||||
|
# If no stub is found, then `#_spectator_stub_fallback` or `#_spectator_abstract_stub_fallback` is called.
|
||||||
private macro abstract_stub(method)
|
private macro abstract_stub(method)
|
||||||
{% raise "Cannot define a stub inside a method" if @def %}
|
{% raise "Cannot define a stub inside a method" if @def %}
|
||||||
{% raise "abstract_stub requires a method definition" if !method.is_a?(Def) %}
|
{% raise "abstract_stub requires a method definition" if !method.is_a?(Def) %}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue