经历了其他类似问题,但问题仍未解决。
测试:
expect{
post message_direct_create_path(friend.id), params: {message_direct:
FactoryBot.attributes_for(:message_direct, user_id: user.id,
friend_id: friend.id)}
}.to change{MessageDirect.count}.by(1)
路线:
post '/message_directs/:friend_id', to: 'message_directs#create', as: 'message_direct_create'
错误:
ActionController::UrlGenerationError:
No route matches {:action=>"/message_directs/1",
:controller=>"message_directs", :message_direct=>{:text=>"Sends
Message", :user_id=>1, :friend_id=>1}}
我也尝试过
:create
和"/message_directs/#{friend.id}"
,但错误仍然相同