Skip to content
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

Merged
merged 1 commit into from
Aug 10, 2021

Conversation

robmathews
Copy link
Contributor

@robmathews robmathews commented Aug 5, 2021

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:

     # ./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'

see here for details, if you care.
https://stackoverflow.com/questions/31816149/difference-between-calling-super-and-calling-super

…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')
Copy link
Contributor

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

?

Copy link
Contributor Author

@robmathews robmathews Aug 9, 2021

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.

Copy link
Contributor Author

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 ...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, seems OK.

Copy link
Contributor

@ofedoren ofedoren left a 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')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, seems OK.

@ofedoren ofedoren merged commit a55d836 into Apipie:master Aug 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants