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

Rails/HttpPositionalArguments does not respect Rack::Test::Methods #99

Closed
jcraigk opened this issue Aug 6, 2019 · 3 comments · Fixed by #969
Closed

Rails/HttpPositionalArguments does not respect Rack::Test::Methods #99

jcraigk opened this issue Aug 6, 2019 · 3 comments · Fixed by #969
Labels
bug Something isn't working

Comments

@jcraigk
Copy link

jcraigk commented Aug 6, 2019

rubocop/rubocop#7095 Expected behavior

In RSpec tests that use Rack::Test::Methods, the Rails/HttpPositionalArguments cop should not warn about using keyword arguments, as that is not how the Rack::Test::Methods work.

Actual behavior

In RSpec tests that include the line include Rack::Test::Methods and then use the get, post, etc methods supplied in that module, the Rails/HttpPositionalArguments mistakenly warns that keyword arguments should be used. However, the Rack::Test::Methods do not support keyword arguments.

From the Rubocop docs:

# bad
get :new, { user_id: 1}

# good
get :new, params: { user_id: 1 }

Steps to reproduce the problem

Run the Rails/HttpPositionalArguments on an RSpec file that includes the line include Rack::Test::Methods and then uses get with at least one parameter.

RuboCop version

$ rubocop -V
0.74.0 (using Parser 2.6.3.0, running on ruby 2.6.3 x86_64-darwin17)

Tangentially related to rubocop/rubocop#3629

@jcraigk jcraigk changed the title Rails/HttpPositionalArguments does not recognize include Rack::Test::Methods Rails/HttpPositionalArguments does not respect Rack::Test::Methods Aug 6, 2019
@koic koic transferred this issue from rubocop/rubocop Aug 6, 2019
@ShPakvel
Copy link

any update on it?

@ezedepetris
Copy link

What version of rack-test are you using?, version 0.7.0 require rubocop < 0.50 and >= 0.49, not sure if it might be related to your issue

@jcraigk
Copy link
Author

jcraigk commented Sep 30, 2021

I'm currently seeing the issue with rack-test 1.1.0 and rubocop-rails 2.12.2

@koic koic added the bug Something isn't working label Mar 31, 2023
koic added a commit to koic/rubocop-rails that referenced this issue Apr 1, 2023
…nts`

Fixes rubocop#99.

This PR fixes a false positive for `Rails/HttpPositionalArguments`
when using `include Rack::Test::Methods`.
koic added a commit to koic/rubocop-rails that referenced this issue Apr 1, 2023
…nts`

Fixes rubocop#99.

This PR fixes a false positive for `Rails/HttpPositionalArguments`
when using `include Rack::Test::Methods`.
koic added a commit to koic/rubocop-rails that referenced this issue Apr 1, 2023
…nts`

Fixes rubocop#99.

This PR fixes a false positive for `Rails/HttpPositionalArguments`
when using `include Rack::Test::Methods`.
@koic koic closed this as completed in #969 Apr 2, 2023
koic added a commit that referenced this issue Apr 2, 2023
…_positional_arguments

[Fix #99] Fix a false positive for `Rails/HttpPositionalArguments`
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.

4 participants