以这种方式传递params会返回与更新前相同的信息。
it "PUT Update updates client" do
client = FactoryGirl.create(:client)
put :update, :id => client, :client => { :name => "Rostyk", :email => "new@email.com" }
expect(client.email).to eq("new@email.com")
expect(client.name).to eq("Rostyk")
end
答案 0 :(得分:1)
:id => client
应为:id => client.id
也许您需要重新加载对象客户端才能看到更新:
client.reload
expect(client.email).to eq("new@email.com")
expect(client.name).to eq("Rostyk")