-
Notifications
You must be signed in to change notification settings - Fork 463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ruby 3.0: fixes the dreaded 'wrong number of arguments (given 1, expected 0)' error. #725
Conversation
…1 + being less explicit. Using just super and not super() fixes the dreaded ' wrong number of arguments (given 1, expected 0) # ./vendor/bundle/ruby/3.0.0/gems/apipie-rails-0.5.19/lib/apipie/extractor/recorder.rb:153:in `process' # ./vendor/bundle/ruby/3.0.0/gems/rails-controller-testing-1.0.5/lib/rails/controller/testing/template_assertions.rb:62:in `process' ' error. see here: https://stackoverflow.com/questions/31816149/difference-between-calling-super-and-calling-super
@@ -150,8 +150,8 @@ def analyze(env, &block) | |||
end | |||
|
|||
module FunctionalTestRecording | |||
def process(*args) # action, parameters = nil, session = nil, flash = nil, http_method = 'GET') | |||
ret = super(*args) | |||
def process(*, **) # action, parameters = nil, session = nil, flash = nil, http_method = 'GET') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it better to use
def process(*args, **kargs)
ret = super
# ...
end
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can. I see both in the rails core. I mean, I literally read the rails source and copied the signature from there, but I don't actually have a strong opinion one way or the other.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it would make you accept the PR, I'll change it ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind, seems OK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @robmathews, merging.
@@ -150,8 +150,8 @@ def analyze(env, &block) | |||
end | |||
|
|||
module FunctionalTestRecording | |||
def process(*args) # action, parameters = nil, session = nil, flash = nil, http_method = 'GET') | |||
ret = super(*args) | |||
def process(*, **) # action, parameters = nil, session = nil, flash = nil, http_method = 'GET') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind, seems OK.
by being less explicit in the super call, ie using just super and not super().
Also, line up the parameter signature with rails 6.0+.
In particular this stack track:
see here for details, if you care.
https://stackoverflow.com/questions/31816149/difference-between-calling-super-and-calling-super