问题
Does anyone knows how can I write a rspec test for these two functions? The update function is used to allow user to edit their information and update. The second function is used to change user's password with requiring user's old password.
def update
@user = current_user
if @user.update_attributes(user_params)
head :no_content
else
render_error(:unprocessable_entity, "Failed to update information")
end
end
def change_password
@user = current_user
if @user.authenticate(params[:password])
@user.update_attributes({:password => params[:password]})
head :no_content
else
render_error(:unprocessable_entity, "Wrong Password!")
end
end
来源:https://stackoverflow.com/questions/47357256/how-to-write-a-rspec-test-for-edit-user-information-function-and-change-password