<commit_before>
module RubyPushNotifications
  module APNS
    describe APNSNotification do
      describe 'building messages for each token' do

        def apns_encode(json, token, id)
          [
            2, 56+json.bytesize, 1, 32, token, 2, json.bytesize, json,
            3, 4, id, 4, 4, (Time.now + APNSNotification::WEEKS_4).to_i, 5, 1, 10
          ].pack 'cNcnH64cna*cnNcnNcnc'
        end

        let(:device_tokens) { ['12', '34'] }
        let(:data) { { a: 1 } }
        let(:notification) { APNSNotification.new device_tokens, data }
        let(:notif_id) { 1 }

        it 'successfully creates the apns binary' do
          json = JSON.dump data
          expect do |b|
            notification.each_message notif_id, &b
          end.to yield_successive_args apns_encode(json, device_tokens[0], notif_id), apns_encode(json, device_tokens[1], notif_id+1)
        end

        it 'validates the data'

        it 'validates the tokens'
      end
    end
  end
end
<commit_msg>added caching spec<commit_after>
module RubyPushNotifications
  module APNS
    describe APNSNotification do
      describe 'building messages for each token' do

        def apns_encode(json, token, id)
          [
            2, 56+json.bytesize, 1, 32, token, 2, json.bytesize, json,
            3, 4, id, 4, 4, (Time.now + APNSNotification::WEEKS_4).to_i, 5, 1, 10
          ].pack 'cNcnH64cna*cnNcnNcnc'
        end

        let(:device_tokens) { ['12', '34'] }
        let(:data) { { a: 1 } }
        let(:notification) { APNSNotification.new device_tokens, data }
        let(:notif_id) { 1 }

        it 'successfully creates the apns binary' do
          json = JSON.dump data
          expect do |b|
            notification.each_message notif_id, &b
          end.to yield_successive_args apns_encode(json, device_tokens[0], notif_id), apns_encode(json, device_tokens[1], notif_id+1)
        end

        it 'caches the payload' do
          expect(JSON).to receive(:dump).with(data).once.and_return 'dummy string'
          notification.each_message(notif_id) { }
        end

        it 'validates the data'

        it 'validates the tokens'
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.10174152153987168, 'fraction_numerical': 0.02474793767186068, 'mean_word_length': 2.2582089552238807, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2766673', 'n_tokens_mistral': 747, 'n_tokens_neox': 698, 'n_words': 191}