私はRailsでこの(確かに恐ろしい)ルートを持っています:
スコープ '/software' do post '/:software_id/:attachment_id/event/*event' => 'software#post_event', as: 'post_event' 終わり
(私はそれを変更しますが、レガシー API の場合)
そして、私はそのための RSpec テストを書いています。
rake routes私に与えます:
post_event POST /software/:software_id/:attachment_id/event/*event(.:format) api/version1301/software#post_event
私のテストは次のようになります。
"post_event" を記述する
「204で応答する必要があります」
パラメータ = {
attachment_id: @attachment.uid,
software_id: @license.id
}
投稿:post_event、params
response.code.should eq "204"
終わり
終わり
しかし、次のルーティング エラーが発生します。
失敗/エラー: post :post_event, params
ActionController::RoutingError:
一致するルートがありませんd522-4a86-b0de-dfb8081e4465", :controller=>"api/version1301/software", :action=>"post_event"}
# ./spec/controllers/api/version1301/software_controller_spec.rb:62:in `ブロック (4 レベル) in'
ワイルドカード (イベント) を使用してルートをどのように処理しますか?