Fix reflection (verify double) on self arg type

There is still an issue with using _ for a placeholder.
This commit is contained in:
Michael Miller 2019-12-13 20:25:18 -07:00
parent 16625cf495
commit 8ccc08b472

View file

@ -7,10 +7,19 @@ module Spectator::Mocks
%source = ::Spectator::Source.new({{meth.filename}}, {{meth.line_number}})
%args = ::Spectator::Mocks::GenericArguments.create(
{% for arg, i in meth.args %}
{% matcher = if arg.restriction
if arg.restriction == :self.id
@type.id
else
arg.restriction
end
else
"::Spectator::Anything.new".id
end %}
{% if meth.splat_index && i == meth.splat_index %}
*{{arg.restriction || "::Spectator::Anything.new".id}}{% if i < meth.args.size %},{% end %}
*{{matcher}}{% if i < meth.args.size %},{% end %}
{% else %}
{{arg.restriction || "::Spectator::Anything.new".id}}{% if i < meth.args.size %},{% end %}
{{matcher}}{% if i < meth.args.size %},{% end %}
{% end %}
{% end %}
)