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

Minitest/AssertRespondTo autocorrect causes ArgumentError: wrong number of arguments (given 1, expected 2..3) #39

Closed
ccasabona opened this issue Nov 7, 2019 · 1 comment · Fixed by #40
Labels
bug Something isn't working

Comments

@ccasabona
Copy link

Given the test statement:

assert respond_to? :token_payment_method

The Minitest/AssertRespond cop auto corrects that to

assert_respond_to(:token_payment_method)

When the test is run, an error message is returned:

ArgumentError: wrong number of arguments (given 1, expected 2..3)

The log message is

[Corrected] Minitest/AssertRespondTo: Prefer using assert_respond_to(:token_payment_method) over assert(respond_to? :token_payment_method).

Minitest assert_respond_to requires an object:

assert_respond_to(obj, meth, msg = nil)

This can be corrected by editing the corrected test statement to:

assert_respond_to(self, :token_payment_method)

Using Rails 6.01, Ruby 2.65, Minitest 5.13.0

@koic koic added the bug Something isn't working label Nov 8, 2019
koic added a commit to koic/rubocop-minitest that referenced this issue Nov 8, 2019
…pondTo`

Fixes rubocop#39.

This PR fixes an incorrect autocorrect for `Minitest/AssertRespondTo` and `Minitest/RefuteRespondTo`
when using assertion method calling `respond_to` with receiver omitted.
@koic
Copy link
Member

koic commented Nov 8, 2019

Thanks for the feedback. I opened a PR #40.

koic added a commit to koic/rubocop-minitest that referenced this issue Nov 8, 2019
…pondTo`

Fixes rubocop#39.

This PR fixes an incorrect autocorrect for `Minitest/AssertRespondTo` and `Minitest/RefuteRespondTo`
when using assertion method calling `respond_to` with receiver omitted.
@koic koic closed this as completed in #40 Nov 8, 2019
koic added a commit that referenced this issue Nov 8, 2019
…ert_respond_to

[Fix #39] Fix an incorrect autocorrect for `Minitest/AssertRespondTo`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants