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

HttpPositionalArguments false offencefor routes.draw #422

Closed
pirj opened this issue Jan 17, 2021 · 3 comments
Closed

HttpPositionalArguments false offencefor routes.draw #422

pirj opened this issue Jan 17, 2021 · 3 comments

Comments

@pirj
Copy link
Member

pirj commented Jan 17, 2021

# spec/controllers/my_spec.rb
RSpec.describy 'My', type: :controller do
  controller(ActionController::Base) do
    # ...
  end

  before(:each) do
    routes.draw do
      get :fetch, to: 'anonymous#fetch'
      get :, to: 'anonymous#with_authenticate'
    end
  end
end
Offenses:

spec/concerns/controllers/my_spec.rb:21:7: C: Rails/HttpPositionalArguments: Use keyword arguments instead of positional arguments for http call: get.
      get :fetch, to: 'anonymous#fetch'
      ^^^

and autocorrects to:

get :fetch, params: { to: 'anonymous#fetch' }

that breaks specs.

Expected behavior

HTTP verbs inside routes.draw are ignored.

Actual behavior

An incorrect auto-correction is made.

Steps to reproduce the problem

See example code.

RuboCop version

$ rubocop -V
1.2.0 (using Parser 2.7.2.0, rubocop-ast 1.1.1, running on ruby 2.5.7 x86_64-linux)
  - rubocop-minitest 0.1.0
  - rubocop-performance 1.8.1
  - rubocop-performance 1.8.1
  - rubocop-rails 2.3.2
  - rubocop-rspec 2.0.0
@koic koic added the bug Something isn't working label Jan 17, 2021
@koic
Copy link
Member

koic commented Jan 22, 2021

The issue reproduction code get :fetch, to: 'anonymous#fetch' is a dup with #180 and resolved by #194. Is there anything else that is in issue?

@koic koic removed the bug Something isn't working label Jan 22, 2021
@pirj
Copy link
Member Author

pirj commented Jan 22, 2021

Thanks for the heads-up!

I seem to have used an outdated version. Sorry for not checking with the most recent one.

@pirj pirj closed this as completed Jan 22, 2021
@koic
Copy link
Member

koic commented Jan 22, 2021

You are welcome!

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

No branches or pull requests

2 participants