我有这条路由:
Rails.application.routes.draw do
get "my_profile", to: "users#show"
end
它创建了这条路由:
my_profile GET /my_profile(.:format) users#show
我可以很容易地在UsersControllerTest
中测试users#show
操作,但我想测试自定义路由是否存在,并在操作上执行代码.比如:
class UsersControllerTest < ActionController::TestCase
def test_my_profile_route
get "/my_profile"
# Testing stuff
end
end
但我得到:
ActionController::UrlGenerationError: No route matches {:action=>"/my_profile", :controller=>"users"}