[英]How to write rspec test for custom routes
我有以下自定義路線:
match '/boeing-737', controller: :planes, action: :display, id: 1000
rspec中的'get'方法僅接受動作名稱,但是可以這樣做:
get :display, id: 1000
我正進入(狀態:
RoutingError:沒有路線與{:id =>“ 1000”,:controller =>“ planes”,:action =>“ display”}匹配
而且沒有選擇可以在測試中獲得“ / boeing-737”。
找到解決方案后,id必須是字符串值,我將其發布在這里,因為我認為該用例在rspec中沒有足夠的文檔說明:
match '/boeing-737', controller: :planes, action: :display, id: '1000'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.