title: Rails Controller Spec. Wrong number of arguments
body: <p>I'm trying to test my controller using RSpec but I'm getting the error below.</p>
  
  <h3>error</h3>
  
  <pre><code>  1) Api::V1::UsersController GET #show responds with 200 status code
       Failure/Error: request.headers.merge!(auth_headers)
  
       ArgumentError:
         wrong number of arguments (given 0, expected 1..2)
       # ./spec/controllers/api/v1/users_controller_spec.rb:9:in `block (3 levels) in &lt;top (required)&gt;'
  
    2) Api::V1::UsersController GET #show returns the serialized user attributes
       Failure/Error: request.headers.merge!(auth_headers)
  
       ArgumentError:
         wrong number of arguments (given 0, expected 1..2)
       # ./spec/controllers/api/v1/users_controller_spec.rb:9:in `block (3 levels) in &lt;top (required)&gt;'
  </code></pre>
  
  <h3>spec</h3>
  
  <pre><code>require 'spec_helper'
  
  describe Api::V1::UsersController, type: :api do
  
    describe 'GET #show' do
      before(:each) do
        @user = FactoryBot.create :user
        auth_headers = @user.create_new_auth_token
        request.headers.merge!(auth_headers)
        get :show, id: @user.id
      end
  
      it 'responds with 200 status code' do
        expect(response.code).to eq('200')
      end
  
      it 'returns the serialized user attributes' do
        expect(json['data']['attributes']).to eq({'name'=&gt;'John Doe', 'email'=&gt;'test@test.com'})
      end
    end
  
  end
  </code></pre>
  
  <h3>spec_helper</h3>
  
  <pre><code>require File.expand_path("../../config/environment", __FILE__)
  Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
  
  
  RSpec.configure do |config|
    config.include ApiHelper, type: :api
    config.include Requests::JsonHelpers, type: :api
  
    config.include FactoryBot::Syntax::Methods
    config.expect_with :rspec do |expectations|
      expectations.include_chain_clauses_in_custom_matcher_descriptions = true
    end
  
    # rspec-mocks config goes here. You can use an alternate test double
    # library (such as bogus or mocha) by changing the `mock_with` option here.
    config.mock_with :rspec do |mocks|
      mocks.verify_partial_doubles = true
    end
    config.shared_context_metadata_behavior = :apply_to_host_groups
  end
  </code></pre>
  
  <h3>api_helper.rb</h3>
  
  <pre><code>module ApiHelper
    include Rack::Test::Methods
  
    def app
      Rails.application
    end
  end  
  </code></pre>
  
  <h3>request_helper.rb</h3>
  
  <pre><code>module Requests
    module JsonHelpers
      def json
        JSON.parse(last_response.body)
      end
    end
  end  
  </code></pre>