mercredi 20 janvier 2016

Undefined method 'signed' for Rack::Test::CookieJar

I have the following test helper:

def log_in_api_as(user, options = {})
  password = options[:password] || 'password'
  post api_sessions_path, api_session: { email: user.email, password: password}
end

Below is the integration test with the error it produces:

test "should work" do
  log_in_api_as(@user)
  assert_equal current_user_api, @user
end

undefined method `signed' for #Rack::Test::CookieJar:0x000000063a3dc8

The error follows the assert_equal line and points to:

def current_user_api
  if user_id = cookies.signed[:user_api_id]
  ...
end

I'm not using Rspec, I'm using cookies for my website without problems. Now implementing it for an api and it doesn't seem to know signed as a method. Does the error perhaps mean the object is incorrect? I saw this related post, but am not sure how this translates to my sitation. How should this be solved?

Aucun commentaire:

Enregistrer un commentaire