I am trying to test a controller action on a non-restful route.
config/routes.rb
:
match '/integration/:provider/callback' => "providers#manual_auth", as: :integration_callback
In my spec file:
spec/controllers/providers_controller_spec.rb
:
describe ProvidersController do
describe '#manual_auth' do
it 'hits the manual_auth action' do
get :manual_auth, use_route: :integration_callback
end
end
end
That gives me an error of:
Failures:
1) ProvidersController#manual_auth hits the manual_auth action
Failure/Error: get :manual_auth, use_route: :integration_callback
ActionController::RoutingError:
No route matches {:controller=>"providers", :action=>"manual_auth"}
However in app/controllers/providers_controller.rb
I have
class ProvidersController < ApplicationController
def manual_auth
logger.info "Got into manual auth"
end
end
I should mention I'm purposely avoiding a request spec here because I need to be able to access and set a session object(that lives in this #manual_auth
action) which apparently can only be done in controller tests, not request specs.
Aucun commentaire:
Enregistrer un commentaire