RSpec:ActionController :: UrlGenerationError:用于自定义网址

时间:2018-09-04 12:06:52

标签: ruby-on-rails rspec

经历了其他类似问题,但问题仍未解决。

测试:

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}",但错误仍然相同

0 个答案:

没有答案