Bit of method cleanup

This commit is contained in:
Michael Miller 2022-03-15 22:55:24 -06:00
parent 332ab1cebc
commit dc74a741cf
No known key found for this signature in database
GPG key ID: AC78B32D30CE34A2
3 changed files with 4 additions and 3 deletions

View file

@ -73,6 +73,7 @@ module Spectator
stub
end
# Returns the double's name formatted for user output.
private def _spectator_stubbed_name : String
{% if anno = @type.annotation(StubbedName) %}
"#<Double " + {{(anno[0] || :Anonymous.id).stringify}} + ">"

View file

@ -73,6 +73,7 @@ module Spectator
stub
end
# Returns the double's name formatted for user output.
private def _spectator_stubbed_name : String
{% if anno = @type.annotation(StubbedName) %}
"#<NullDouble " + {{(anno[0] || :Anonymous.id).stringify}} + ">"

View file

@ -16,9 +16,6 @@ module Spectator
# or nil if no stubs satisfy it.
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.
#
# 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.
# If no stub is found, then `#_spectator_stub_fallback` or `#_spectator_abstract_stub_fallback` is called.
private macro stub(method)
{% raise "Cannot define a stub inside a method" if @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.
# If no stub is found, then `#_spectator_stub_fallback` or `#_spectator_abstract_stub_fallback` is called.
private macro abstract_stub(method)
{% raise "Cannot define a stub inside a method" if @def %}
{% raise "abstract_stub requires a method definition" if !method.is_a?(Def) %}