Fix stub_type when used on a sub-type

previous_def should only be used if the type being stubbed matches the type stub methods are defined in.
Re-enable tests for define_subclass mocking.
This commit is contained in:
Michael Miller 2022-05-15 10:59:44 -06:00
parent 86b49dc20e
commit 1adcf74c3f
No known key found for this signature in database
GPG key ID: 32B47AE8F388A1FF
2 changed files with 42 additions and 39 deletions

View file

@ -318,7 +318,7 @@ module Spectator
{% if method.double_splat %}**{{method.double_splat}}, {% end %}
{% if method.block_arg %}&{{method.block_arg}}{% elsif method.accepts_block? %}&{% end %}
){% if method.return_type %} : {{method.return_type}}{% end %}{% if !method.free_vars.empty? %} forall {{method.free_vars.splat}}{% end %}
previous_def{% if method.accepts_block? %} { |*%yargs| yield *%yargs }{% end %}
{% if type == @type %}previous_def{% else %}super{% end %}{% if method.accepts_block? %} { |*%yargs| yield *%yargs }{% end %}
end
{% end %}
end