2

我使用 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

我该如何解决这个问题?我等你的想法。提前致谢。

4

1 回答 1

2

您忘记在您的路线中替换 :provider 参数。试试这个:

assert_routing "/auth/identity/callback", 
  :controller => "sessions",
  :action => "create",
  "provider"=>"identity"
于 2013-03-12T14:46:49.737 回答