mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Don't capture original block as proc
This commit is contained in:
parent
35f8779ceb
commit
31d68a9ca3
7 changed files with 8 additions and 8 deletions
|
@ -7,7 +7,7 @@ module Spectator::Mocks
|
||||||
super(name, location, args)
|
super(name, location, args)
|
||||||
end
|
end
|
||||||
|
|
||||||
def call(_args : GenericArguments(T, NT), &_original : -> RT) forall T, NT, RT
|
def call(_args : GenericArguments(T, NT), & : -> RT) forall T, NT, RT
|
||||||
raise @exception
|
raise @exception
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,9 +14,9 @@ module Spectator::Mocks
|
||||||
@name == call.name
|
@name == call.name
|
||||||
end
|
end
|
||||||
|
|
||||||
abstract def call(args : GenericArguments(T, NT), &original : -> RT) forall T, NT, RT
|
abstract def call(args : GenericArguments(T, NT), & : -> RT) forall T, NT, RT
|
||||||
|
|
||||||
def call!(args : GenericArguments(T, NT), &original : -> RT) : RT forall T, NT, RT
|
def call!(args : GenericArguments(T, NT), & : -> RT) : RT forall T, NT, RT
|
||||||
value = call(args) { |*ya| yield *ya }
|
value = call(args) { |*ya| yield *ya }
|
||||||
if value.is_a?(RT)
|
if value.is_a?(RT)
|
||||||
value.as(RT)
|
value.as(RT)
|
||||||
|
|
|
@ -10,7 +10,7 @@ module Spectator::Mocks
|
||||||
raise ArgumentError.new("Values must have at least one item") if @values.size < 1
|
raise ArgumentError.new("Values must have at least one item") if @values.size < 1
|
||||||
end
|
end
|
||||||
|
|
||||||
def call(_args : GenericArguments(T, NT), &_original : -> RT) forall T, NT, RT
|
def call(_args : GenericArguments(T, NT), & : -> RT) forall T, NT, RT
|
||||||
value = @values[@index]
|
value = @values[@index]
|
||||||
@index += 1 if @index < @values.size - 1
|
@index += 1 if @index < @values.size - 1
|
||||||
value
|
value
|
||||||
|
|
|
@ -4,7 +4,7 @@ require "./value_method_stub"
|
||||||
|
|
||||||
module Spectator::Mocks
|
module Spectator::Mocks
|
||||||
class NilMethodStub < GenericMethodStub(Nil)
|
class NilMethodStub < GenericMethodStub(Nil)
|
||||||
def call(_args : GenericArguments(T, NT), &_original : -> RT) forall T, NT, RT
|
def call(_args : GenericArguments(T, NT), & : -> RT) forall T, NT, RT
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ require "./generic_method_stub"
|
||||||
|
|
||||||
module Spectator::Mocks
|
module Spectator::Mocks
|
||||||
class OriginalMethodStub < GenericMethodStub(Nil)
|
class OriginalMethodStub < GenericMethodStub(Nil)
|
||||||
def call(_args : GenericArguments(T, NT), &_original : -> RT) forall T, NT, RT
|
def call(_args : GenericArguments(T, NT), & : -> RT) forall T, NT, RT
|
||||||
yield
|
yield
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,7 +11,7 @@ module Spectator::Mocks
|
||||||
ProcMethodStub.new(name, location, block, args)
|
ProcMethodStub.new(name, location, block, args)
|
||||||
end
|
end
|
||||||
|
|
||||||
def call(_args : GenericArguments(T, NT), &_original : -> RT) forall T, NT, RT
|
def call(_args : GenericArguments(T, NT), & : -> RT) forall T, NT, RT
|
||||||
@proc.call
|
@proc.call
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,7 +7,7 @@ module Spectator::Mocks
|
||||||
super(name, location, args)
|
super(name, location, args)
|
||||||
end
|
end
|
||||||
|
|
||||||
def call(_args : GenericArguments(T, NT), &_original : -> RT) forall T, NT, RT
|
def call(_args : GenericArguments(T, NT), & : -> RT) forall T, NT, RT
|
||||||
@value
|
@value
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue