I am working on michal hart Ruby in a rail guide in chapter 8. Click here for details , I'm stuck in exercise 8.6. The author presented a way to access the remember_token virtual attribute in the integration test, and he left some work for us,
assert_equal assigns(:user).FILL_IN, FILL_IN
I have to replace the correct code with the FILL_IN placeholder. I just couldn't think about the right one. I tried using
assert_equal assigns(:user).cookies, remember_token
application / controllers / sessions_controller.rb
def create @user = User.find_by(email: params[:session][:email].downcase) if @user && @user.authenticate(params[:session][:password]) log_in @user params[:session][:remember_me] == '1' ? remember(@user) : forget(@user) redirect_to @user
But that did not work, Erros:
"test_login_with_remembering", UsersLoginTest, 0.590876] test_login_with_remembering#UsersLoginTest (0.59s) NoMethodError: NoMethodError: undefined method `cookies' for #<User:0x007f964f1a91d0>
I know that this is very simple, I really did some research, it seems no one asked the same question, because the textbook is completely new. Please understand that I'm just a beginner, I would really appreciate it if you could help me solve this problem.
source share