Reputation: 539
I use minitest for testing framework. I try to test routes.
routes.rb
match "/auth/:provider/callback", to: "sessions#create", :as => sessioncallback
I want to test this route. I try a code like below:
assert_routing "/auth/:provider/callback", :controller => "sessions", :action => "create", "provider"=>"identity"
But I didn't get success from this routing test. It gives:
ActionController::RoutingError: No route matches {:controller=>"sessions", :action=>"create"}
I ran rake routes
command. My routes like below:
sessions GET /sessions(.:format) sessions#index
POST /sessions(.:format) sessions#create
new_session GET /sessions/new(.:format) sessions#new
edit_session GET /sessions/:id/edit(.:format) sessions#edit
session GET /sessions/:id(.:format) sessions#show
PUT /sessions/:id(.:format) sessions#update
DELETE /sessions/:id(.:format) sessions#destroy
sessioncallback /auth/:provider/callback(.:format) sessions#create
How can i solve this? I wait your ideas. Thanks in advance.
Upvotes: 2
Views: 784
Reputation: 3276
You forgot to substitute the :provider param in your route. Try this instead:
assert_routing "/auth/identity/callback",
:controller => "sessions",
:action => "create",
"provider"=>"identity"
Upvotes: 2