我使用 minitest 来测试框架。我尝试测试路线。
routes.rb
match "/auth/:provider/callback", to: "sessions#create", :as => sessioncallback
我想测试这条路线。我尝试如下代码:
assert_routing "/auth/:provider/callback", :controller => "sessions", :action => "create", "provider"=>"identity"
但是我没有从这个路由测试中获得成功。它给:
ActionController::RoutingError: No route matches {:controller=>"sessions", :action=>"create"}
我跑了rake routes
命令。我的路线如下:
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
我该如何解决这个问题?我等你的想法。提前致谢。