Skip to content

Commit

Permalink
Fix splat argument expansion in method redefinition
Browse files Browse the repository at this point in the history
The constructed previous_def call was malformed for stub methods.
Resolves the original issue in
#49
  • Loading branch information
icy-arctic-fox committed Jan 23, 2023
1 parent fd37222 commit abbd6ff
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 6 additions & 0 deletions spec/issues/github_issue_49_spec.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
require "../spec_helper"

# https://github.com/icy-arctic-fox/spectator/issues/49
Spectator.describe "GitHub Issue #49" do
mock File
end
8 changes: 3 additions & 5 deletions src/spectator/mocks/stubbable.cr
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,12 @@ module Spectator
if method.splat_index
method.args.each_with_index do |arg, i|
if i == method.splat_index
original += '*'
if arg.internal_name && arg.internal_name.size > 0
original += "#{arg.internal_name}, "
original += "*#{arg.internal_name}, "
end
original += "**#{method.double_splat}, " if method.double_splat
elsif i > method.splat_index
original += "#{arg.name}: #{arg.internal_name}"
original += "#{arg.name}: #{arg.internal_name}, "
else
original += "#{arg.internal_name}, "
end
Expand Down Expand Up @@ -283,9 +282,8 @@ module Spectator
if method.splat_index
method.args.each_with_index do |arg, i|
if i == method.splat_index
original += '*'
if arg.internal_name && arg.internal_name.size > 0
original += "#{arg.internal_name}, "
original += "*#{arg.internal_name}, "
end
original += "**#{method.double_splat}, " if method.double_splat
elsif i > method.splat_index
Expand Down

0 comments on commit abbd6ff

Please sign in to comment.