Harry B. Harry B. - 1 month ago 15
Ruby Question

DEPRECATION WARNING: ActionController::TestCase HTTP request methods will accept only keyword arguments

I keep getting this warning even after I've tried fixing the format to match the example that is given once the test is written as well examples from articles online explaining how to fix the issues. I would like to do this correctly so that I won't have to worry about not testing correctly and also so that I don't get 40 warnings every time I run the full test suite

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

Answer

You're getting this from your CREATE Example, where you're passing params in the old style.

Change this:

post :create, :food => food_params

To this:

post :create, params: { food: food_params }
Comments