0

routes get '/foo/bar' => foo/bar#index {:custom_auth => [:admin]}

I have the route with custom_auth specified in config/routes.rb file.

While invoking index method from controller spec, it complains about route not found which works well without custom_auth parameter removed from routes config.

Is there a way to pass custom_auth while invoking the controller/action from controller spec ?

   describe Foo::BarsController do
     describe 'GET index' do
        get :index
        expect(response).to eq {}
      end
   end

config/routes.rb

get '/foo/bar', :to => 'foo/bar#index', :custom_auth => [:admin]

1 Answer 1

0

You can pass all the required params in a params hash while invoking get :index request.

So, build a params hash and then pass that to the get :index call like this:

let(:admin) { double('admin') }
let(:custom_auth_params) { { :custom_auth => [:admin] } }
get :index, custom_auth_params
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.