0
votes

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

1 Answers

0
votes

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