You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: authenticated_session_helper.rb
    path of file: ./repos/vets-api/spec/support
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

module AuthenticatedSessionHelper
  def sign_in(user = FactoryBot.build(:user, :loa3), token = nil, raw = false)
    user = user.p
    
  def sign_in(user = FactoryBot.build(:user, :loa3), token = nil, raw = false)
    user = user.persisted? ? user : User.create(user)
    token ||= 'abracadabra'
    session_object = Session.create(uuid: user.uuid, token:)
    session_options = { key: 'api_session', secure: false, http_only: true }
    if raw
      Rails::SessionCookie::App.new(session_object.to_hash, session_options).session_cookie
    elsif cookies.is_a?(ActionDispatch::Cookies::CookieJar)
      request.session = ActionController::TestSession.new(session_object.to_hash)
    else
      raw_session_cookie = Rails::SessionCookie::App.new(session_object.to_hash, session_options).session_cookie
      cookies.merge(raw_session_cookie)
      raw_session_cookie
    end