mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Handle super vs previous_def
This commit is contained in:
parent
66dc6bf098
commit
c03808dfce
1 changed files with 10 additions and 4 deletions
|
@ -25,6 +25,12 @@ module Spectator::Mocks
|
||||||
else
|
else
|
||||||
raise "Unrecognized stub format"
|
raise "Unrecognized stub format"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
original = if @type.methods.find { |m| m.name.id == name }
|
||||||
|
:previous_def
|
||||||
|
else
|
||||||
|
:super
|
||||||
|
end.id
|
||||||
%}
|
%}
|
||||||
|
|
||||||
def {{name}}({{params.splat}}){% if definition.is_a?(TypeDeclaration) %} : {{definition.type}}{% end %}
|
def {{name}}({{params.splat}}){% if definition.is_a?(TypeDeclaration) %} : {{definition.type}}{% end %}
|
||||||
|
@ -32,9 +38,9 @@ module Spectator::Mocks
|
||||||
%call = ::Spectator::Mocks::GenericMethodCall.new({{name.symbolize}}, %args)
|
%call = ::Spectator::Mocks::GenericMethodCall.new({{name.symbolize}}, %args)
|
||||||
::Spectator::Mocks::Registry.record_call(self, %call)
|
::Spectator::Mocks::Registry.record_call(self, %call)
|
||||||
if (%stub = ::Spectator::Mocks::Registry.find_stub(self, %call))
|
if (%stub = ::Spectator::Mocks::Registry.find_stub(self, %call))
|
||||||
%stub.call(%args, typeof(previous_def({{args.splat}})))
|
%stub.call(%args, typeof({{original}}({{args.splat}})))
|
||||||
else
|
else
|
||||||
previous_def({{args.splat}})
|
{{original}}({{args.splat}})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -43,9 +49,9 @@ module Spectator::Mocks
|
||||||
%call = ::Spectator::Mocks::GenericMethodCall.new({{name.symbolize}}, %args)
|
%call = ::Spectator::Mocks::GenericMethodCall.new({{name.symbolize}}, %args)
|
||||||
::Spectator::Mocks::Registry.record_call(self, %call)
|
::Spectator::Mocks::Registry.record_call(self, %call)
|
||||||
if (%stub = ::Spectator::Mocks::Registry.find_stub(self, %call))
|
if (%stub = ::Spectator::Mocks::Registry.find_stub(self, %call))
|
||||||
%stub.call(%args, typeof(previous_def({{args.splat}}) { |*%ya| yield *%ya }))
|
%stub.call(%args, typeof({{original}}({{args.splat}}) { |*%ya| yield *%ya }))
|
||||||
else
|
else
|
||||||
previous_def({{args.splat}}) do |*%yield_args|
|
{{original}}({{args.splat}}) do |*%yield_args|
|
||||||
yield *%yield_args
|
yield *%yield_args
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue