[英]DEPRECATION WARNING: ActionController::TestCase HTTP request methods will accept only keyword arguments in future Rails versions
[英]DEPRECATION WARNING: ActionController::TestCase HTTP request methods will accept only keyword arguments
即使在我尝试修改格式以匹配测试编写后给出的示例以及在线文章中解释如何解决问题的示例之后,我仍然会收到此警告。 我想这样做是正确的,这样我就不必担心没有正确测试,所以每次运行完整的测试套件时我都不会得到40个警告
GET example
it "renders the #show view" do
food = create(:food)
get :show, params: { id: food.id }
expect(response).to render_template :show
end
CREATE Example
it "redirects to user page of user who uploaded food" do
food_params = FactoryGirl.attributes_for(:food)
post :create, :food => food_params
expect(response).to redirect_to user_path(@user.id)
end
SHOW example
it "assigns the requested food to @food" do
food = create(:food)
get :show, params: { id: food.id }
expect(assigns(:food)).to eq(food)
end
DELETE
it "deletes the food" do
expect{ delete :destroy, id: @food}.to change(Food, :count).by(-1)
end
it "redirects to user page of user who deleted food" do
delete :destroy, id: @food
expect(response).to redirect_to user_path(@user.id)
end
PUT
it "located the requested @food" do
put :update, id: @food, food: FactoryGirl.attributes_for(:food)
expect(assigns(:food)).to eq(@food)
end
it "changes @food's attributes" do
put :update, id: @food,
food: FactoryGirl.attributes_for(:food, title: "Yummers", kind: "Salad")
@food.reload
expect(@food.title).to eq("Yummers")
expect(@food.kind).to eq("Salad")
end
你从你的CREATE示例中得到了这个,你在旧式中传递params。
改变这个:
post :create, :food => food_params
对此:
post :create, params: { food: food_params }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.