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) %}
|
||||
%source = ::Spectator::Source.new({{_file}}, {{_line}})
|
||||
%proc = ->{
|
||||
def {{receiver}}%method({{params.splat}}){% if definition.is_a?(TypeDeclaration) %} : {{definition.type}}{% end %}
|
||||
{{body.body}}
|
||||
}
|
||||
%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 %}
|
||||
|
@ -66,8 +63,15 @@ module Spectator::Mocks
|
|||
if (%stub = %harness.mocks.find_stub(self, %call))
|
||||
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
|
||||
|
||||
def {{receiver}}{{name}}({{params.splat}}){% if definition.is_a?(TypeDeclaration) %} : {{definition.type}}{% end %}
|
||||
|
@ -78,7 +82,15 @@ module Spectator::Mocks
|
|||
if (%stub = %harness.mocks.find_stub(self, %call))
|
||||
return %stub.call!(%args) { {{original}}({{args.splat}}) { |*%ya| yield *%ya } }
|
||||
end
|
||||
|
||||
{% if body && !body.is_a?(Nop) %}
|
||||
%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
|
||||
|
@ -86,3 +98,4 @@ module Spectator::Mocks
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue