mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Resolve issue with harness trying to be used outside of test
This commit is contained in:
parent
11ea7bf2ce
commit
f816a64770
1 changed files with 17 additions and 15 deletions
|
@ -34,27 +34,29 @@ module Spectator::Mocks
|
||||||
%}
|
%}
|
||||||
|
|
||||||
def {{name}}({{params.splat}}){% if definition.is_a?(TypeDeclaration) %} : {{definition.type}}{% end %}
|
def {{name}}({{params.splat}}){% if definition.is_a?(TypeDeclaration) %} : {{definition.type}}{% end %}
|
||||||
%args = ::Spectator::Mocks::GenericArguments.create({{args.splat}})
|
if (%harness = ::Spectator::Harness.current?)
|
||||||
%call = ::Spectator::Mocks::GenericMethodCall.new({{name.symbolize}}, %args)
|
%args = ::Spectator::Mocks::GenericArguments.create({{args.splat}})
|
||||||
::Spectator::Harness.current.mocks.record_call(self, %call)
|
%call = ::Spectator::Mocks::GenericMethodCall.new({{name.symbolize}}, %args)
|
||||||
if (%stub = ::Spectator::Harness.current.mocks.find_stub(self, %call))
|
%harness.mocks.record_call(self, %call)
|
||||||
%stub.call!(%args, typeof({{original}}({{args.splat}})))
|
if (%stub = ::Spectator::Harness.current.mocks.find_stub(self, %call))
|
||||||
else
|
return %stub.call!(%args, typeof({{original}}({{args.splat}})))
|
||||||
{{original}}({{args.splat}})
|
end
|
||||||
end
|
end
|
||||||
|
{{original}}({{args.splat}})
|
||||||
end
|
end
|
||||||
|
|
||||||
def {{name}}({{params.splat}}){% if definition.is_a?(TypeDeclaration) %} : {{definition.type}}{% end %}
|
def {{name}}({{params.splat}}){% if definition.is_a?(TypeDeclaration) %} : {{definition.type}}{% end %}
|
||||||
%args = ::Spectator::Mocks::GenericArguments.create({{args.splat}})
|
if (%harness = ::Spectator::Harness.current?)
|
||||||
%call = ::Spectator::Mocks::GenericMethodCall.new({{name.symbolize}}, %args)
|
%args = ::Spectator::Mocks::GenericArguments.create({{args.splat}})
|
||||||
::Spectator::Harness.current.mocks.record_call(self, %call)
|
%call = ::Spectator::Mocks::GenericMethodCall.new({{name.symbolize}}, %args)
|
||||||
if (%stub = ::Spectator::Harness.current.mocks.find_stub(self, %call))
|
%harness.mocks.record_call(self, %call)
|
||||||
%stub.call!(%args, typeof({{original}}({{args.splat}}) { |*%ya| yield *%ya }))
|
if (%stub = ::Spectator::Harness.current.mocks.find_stub(self, %call))
|
||||||
else
|
return %stub.call!(%args, typeof({{original}}({{args.splat}}) { |*%ya| yield *%ya }))
|
||||||
{{original}}({{args.splat}}) do |*%yield_args|
|
|
||||||
yield *%yield_args
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
{{original}}({{args.splat}}) do |*%yield_args|
|
||||||
|
yield *%yield_args
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue