<commit_before># frozen_string_literal: true
module Pragma
  module Test
    module Helper
      def self.included(klass)
        klass.extend ClassMethods
      end

      module ClassMethods
        def authenticate_as(user)
          before do
            token = Knock::AuthToken.new(payload: { sub: user.id }).token
            header 'Authorization', "Bearer #{token}"
          end
        end
      end
    end
  end
end
<commit_msg>Add missing documentation<commit_after># frozen_string_literal: true
module Pragma
  module Test
    # Provides RSpec helpers for authenticating in tests.
    #
    # @author <NAME>
    module Helper
      def self.included(klass)
        klass.extend ClassMethods
      end

      module ClassMethods # :nodoc:
        # Authenticate as the given user by setting the appropriate JWT in the +Authorization+
        # header.
        #
        # @param user [Object] user to authenticate with
        def authenticate_as(user)
          before do
            token = Knock::AuthToken.new(payload: { sub: user.id }).token
            header 'Authorization', "Bearer #{token}"
          end
        end
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.07014542343883662, 'fraction_numerical': 0.0, 'mean_word_length': 2.06282722513089, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '906033', 'n_tokens_mistral': 324, 'n_tokens_neox': 319, 'n_words': 103}