mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Hacky solution for https://gitlab.com/arctic-fox/spectator/-/issues/44
Don't use a proc stub, which doesn't support arguments.
This commit is contained in:
parent
5c24d606dd
commit
68bac59cab
1 changed files with 22 additions and 9 deletions
|
@ -50,12 +50,9 @@ module Spectator::Mocks
|
||||||
%}
|
%}
|
||||||
|
|
||||||
{% if body && !body.is_a?(Nop) %}
|
{% if body && !body.is_a?(Nop) %}
|
||||||
%source = ::Spectator::Source.new({{_file}}, {{_line}})
|
def {{receiver}}%method({{params.splat}}){% if definition.is_a?(TypeDeclaration) %} : {{definition.type}}{% end %}
|
||||||
%proc = ->{
|
|
||||||
{{body.body}}
|
{{body.body}}
|
||||||
}
|
end
|
||||||
%ds = ::Spectator::Mocks::ProcMethodStub.new({{name.symbolize}}, %source, %proc)
|
|
||||||
::Spectator::SpecBuilder.add_default_stub({{@type.name}}, %ds)
|
|
||||||
{% end %}
|
{% end %}
|
||||||
|
|
||||||
def {{receiver}}{{name}}({{params.splat}}){% if definition.is_a?(TypeDeclaration) %} : {{definition.type}}{% end %}
|
def {{receiver}}{{name}}({{params.splat}}){% if definition.is_a?(TypeDeclaration) %} : {{definition.type}}{% end %}
|
||||||
|
@ -66,8 +63,15 @@ module Spectator::Mocks
|
||||||
if (%stub = %harness.mocks.find_stub(self, %call))
|
if (%stub = %harness.mocks.find_stub(self, %call))
|
||||||
return %stub.call!(%args) { {{original}}({{args.splat}}) }
|
return %stub.call!(%args) { {{original}}({{args.splat}}) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
{% if body && !body.is_a?(Nop) %}
|
||||||
|
%method({{args.splat}})
|
||||||
|
{% else %}
|
||||||
|
{{original}}({{args.splat}})
|
||||||
|
{% end %}
|
||||||
|
else
|
||||||
|
{{original}}({{args.splat}})
|
||||||
end
|
end
|
||||||
{{original}}({{args.splat}})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def {{receiver}}{{name}}({{params.splat}}){% if definition.is_a?(TypeDeclaration) %} : {{definition.type}}{% end %}
|
def {{receiver}}{{name}}({{params.splat}}){% if definition.is_a?(TypeDeclaration) %} : {{definition.type}}{% end %}
|
||||||
|
@ -78,9 +82,18 @@ module Spectator::Mocks
|
||||||
if (%stub = %harness.mocks.find_stub(self, %call))
|
if (%stub = %harness.mocks.find_stub(self, %call))
|
||||||
return %stub.call!(%args) { {{original}}({{args.splat}}) { |*%ya| yield *%ya } }
|
return %stub.call!(%args) { {{original}}({{args.splat}}) { |*%ya| yield *%ya } }
|
||||||
end
|
end
|
||||||
end
|
|
||||||
{{original}}({{args.splat}}) do |*%yield_args|
|
{% if body && !body.is_a?(Nop) %}
|
||||||
yield *%yield_args
|
%method({{args.splat}}) { {{original}}({{args.splat}}) { |*%ya| yield *%ya } }
|
||||||
|
{% else %}
|
||||||
|
{{original}}({{args.splat}}) do |*%yield_args|
|
||||||
|
yield *%yield_args
|
||||||
|
end
|
||||||
|
{% end %}
|
||||||
|
else
|
||||||
|
{{original}}({{args.splat}}) do |*%yield_args|
|
||||||
|
yield *%yield_args
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue