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"}
如何正确发送到我想要的网址?我尝试了各种各样的变化,但我在这里错过了一些魔术酱。