[英]How can I test with rspec different routes but to the same controller method?
我可以解釋。
在我的路線上我有這個:
resources :questions, :path => 'pq', only: [:index, :show, :create] do
#many other routes...
member do
post :up_vote, action: :vote, vote: 1
post :down_vote, action: :vote, vote: -1
end
end
你可以觀察到,它有兩條相同動作的路線,但兩者都發送一個參數'投票'。
我嘗試用rspec測試:
before{ post :up_vote, id: 1 }
要么
before{ post :vote, id: 1, vote: 1 }
但我沒有成功,總是返回No routes matches
任何人都知道如何用rspec測試它?
刪除resources
行上的only
條款並重新測試。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.