【发布时间】:2018-06-28 01:44:14
【问题描述】:
我正在使用 Rails 5 和 minitest。如何在我的测试中引用创建 URL,以测试控制器的创建方法?在我的路线文件中,我有
resources :items
在我的测试文件中,我有
test "do create" do
person = people(:one)
rating = 10
post items_create_url, params: {person_id: person.id, rating: rating}
# Verify we got the proper response
assert_response :success
end
但是,上面的测试以
结束undefined local variable or method `items_create_url'
错误。在测试中引用我的 create 方法的正确方法是什么?
【问题讨论】:
标签: unit-testing controller routes ruby-on-rails-5 minitest