If you're using Rails 4, use PATCH instead of PUT; PUT still works, but PATCH is now preferred. To test that, try this:
describe "PATCH #update" do
context "with good data" do
it "updates the wallet and redirects" do
patch :update, id: @wallet.id, wallet: { name: "xyz", balance: "20.2"}
expect(response).to be_redirect
end
end
context "with bad data" do
it "does not change the wallet, and re-renders the form" do
patch :update, id: @wallet.id, wallet: { name: "xyz", balance: "two"}
expect(response).not_to be_redirect
end
end
end
You can make the expect clauses more specific, but that's a start. If you want to test the json part of the code, just add format: 'json'
to the params hash.