0
我跑rails g devise:controllers users
和我的路線看起來像測試覆蓋設計的控制器 - 「無路由匹配」
devise_for :users, controllers: {
sessions: 'sessions'
}
我有一個app/controllers/users/sessions_controller
,我想測試。我的路線是這樣的:
$ rake routes
Prefix Verb URI Pattern Controller#Action
new_user_session GET /users/sign_in(.:format) sessions#new
user_session POST /users/sign_in(.:format) sessions#create
我建立了我的測試是這樣的:
# test/controllers/users/sessions_controller_test.rb
require 'test_helper'
class SessionsControllerTest < ActionController::TestCase
tests Users::SessionsController
test "sign in sanity check" do
user = users(:one)
post :create, email: user.email, password: 'password'
assert_response :success
end
end
哪個失敗,出現錯誤:
ActionController::UrlGenerationError: No route matches {:action=>"create", :controller=>"users/sessions", :email=>"[email protected]", :password=>"password"}
如何正確發送到我想要的網址?我嘗試了各種各樣的變化,但我在這裏錯過了一些魔術醬。