Pass along original block

This commit is contained in:
Michael Miller 2019-11-20 16:29:06 -07:00
parent 2dee50f19e
commit f8563e86c7
6 changed files with 7 additions and 7 deletions

View file

@ -7,7 +7,7 @@ module Spectator::Mocks
super(name, source, args)
end
def call(_args : GenericArguments(T2, NT2)) forall T2, NT2
def call(_args : GenericArguments(T, NT), &_original : -> RT) forall T, NT, RT
raise @exception
end
end

View file

@ -14,10 +14,10 @@ module Spectator::Mocks
@name == call.name
end
abstract def call(args : GenericArguments(T, NT)) forall T, NT
abstract def call(args : GenericArguments(T, NT), &original : -> RT) forall T, NT, RT
def call!(args : GenericArguments(T, NT), &original : -> RT) : RT forall T, NT, RT
value = call(args)
value = call(args, &original)
if value.is_a?(RT)
value.as(RT)
else

View file

@ -10,7 +10,7 @@ module Spectator::Mocks
raise ArgumentError.new("Values must have at least one item") if @values.size < 1
end
def call(_args : GenericArguments(T2, NT2)) forall T2, NT2
def call(_args : GenericArguments(T, NT), &_original : -> RT) forall T, NT, RT
value = @values[@index]
@index += 1 if @index < @values.size - 1
value

View file

@ -4,7 +4,7 @@ require "./value_method_stub"
module Spectator::Mocks
class NilMethodStub < GenericMethodStub(Nil)
def call(_args : GenericArguments(T, NT)) forall T, NT
def call(_args : GenericArguments(T, NT), &_original : -> RT) forall T, NT, RT
nil
end

View file

@ -11,7 +11,7 @@ module Spectator::Mocks
ProcMethodStub.new(name, source, block, args)
end
def call(_args : GenericArguments(T2, NT2)) forall T2, NT2
def call(_args : GenericArguments(T, NT), &_original : -> RT) forall T, NT, RT
@proc.call
end
end

View file

@ -7,7 +7,7 @@ module Spectator::Mocks
super(name, source, args)
end
def call(_args : GenericArguments(T2, NT2)) forall T2, NT2
def call(_args : GenericArguments(T, NT), &_original : -> RT) forall T, NT, RT
@value
end
end