Skip to content

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

Closed
@obfuscoder

Description

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)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions