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 false positive when defining route in spec #180

Closed
obfuscoder opened this issue Dec 28, 2019 · 0 comments · Fixed by #194
Closed

Rails/HttpPositionalArguments false positive when defining route in spec #180

obfuscoder opened this issue Dec 28, 2019 · 0 comments · Fixed by #194
Labels
bug Something isn't working

Comments

@obfuscoder
Copy link

Defining a controller in a test/spec and adding a route for that controller within the test/spec will result in this rule to be picked up incorrectly.

Example:

require 'rails_helper'

module Admin
  RSpec.describe AdminController do
    controller do
      def test
        render plain: 'test'
      end
    end

    before do
      @routes.draw do
        get '/test', to: 'admin/admin#test'
      end
      get '/test'
    end
    # ...
  end
end

Expected behavior

The defined route should not be complained about by this rule.

Actual behavior

Rubocop complains with:

spec/controllers/admin/admin_controller_spec.rb:18:9: C: Rails/HttpPositionalArguments: Use keyword arguments instead of positional arguments for http call: get.
        get '/test', to: 'admin/admin#test'
        ^^^

RuboCop version

0.78.0 (using Parser 2.7.0.0, running on ruby 2.5.3 x86_64-linux)

@koic koic added the bug Something isn't working label Jan 25, 2020
koic added a commit to koic/rubocop-rails that referenced this issue Jan 27, 2020
Fixes rubocop#180

This PR fixes a false positive for `HttpPositionalArguments`
when using `get` method with `:to` option.
@koic koic closed this as completed in #194 Feb 2, 2020
koic added a commit that referenced this issue Feb 2, 2020
…ional_arguments

[Fix #180] Fix a false positive for `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.

2 participants