Reputation: 5164
I am testing the delete action of my resource controller as follows:
describe ResourceController do
context "DELETE destroy" do
before :each do
delete :destroy, id: @resource.id
end
it { should respond_with(:no_content) }
end
end
I expect a 204/no-content response. However, this test is failing as the response returned by the server is a 406. The response is a 204 when I hit the controller directly from my Rest test client.
Upvotes: 11
Views: 5535
Reputation: 4391
A couple of years have passed...
I would just like to note that it is possible to use the expect
syntax and to query the status code directly.
describe ResourceController do
context "DELETE destroy" do
it "should respond with a 204"
delete :destroy, id: @resource.id
expect(response).to have_http_status(:no_content)
end
end
end
Upvotes: 9