<commit_before>
module RubyPushNotifications
  module APNS
    describe APNSConnection do

      let(:cert) { File.read 'spec/support/dummy.pem' }
      let(:tcp_socket) { instance_double(TCPSocket).as_null_object }
      let(:ssl_socket) { instance_double(OpenSSL::SSL::SSLSocket).as_null_object }

      describe '::open' do
        before do
          allow(TCPSocket).to receive(:new).with('gateway.sandbox.push.apple.com', 2195).and_return tcp_socket
          allow(OpenSSL::SSL::SSLSocket).to receive(:new).with(tcp_socket, an_instance_of(OpenSSL::SSL::SSLContext)).and_return ssl_socket
        end

        it 'creates the connection' do
          expect(TCPSocket).to receive(:new).with('gateway.sandbox.push.apple.com', 2195).and_return tcp_socket
          expect(OpenSSL::SSL::SSLSocket).to receive(:new).with(tcp_socket, an_instance_of(OpenSSL::SSL::SSLContext)).and_return ssl_socket
          APNSConnection.open cert, true
        end

        it 'returns an instance of APNSConnection' do
          expect(APNSConnection.open cert, true).to be_a APNSConnection
        end

        it 'sets the password for pem file' do
          expect(OpenSSL::SSL::SSLSocket).to receive(:new).with(tcp_socket, an_instance_of(OpenSSL::SSL::SSLContext)).and_return ssl_socket
          expect(OpenSSL::PKey::RSA).to receive(:new).with(cert, 'password')
          expect(APNSConnection.open cert, true, 'password').to be_a APNSConnection
        end
      end

      describe '#close' do
        let(:connection) { APNSConnection.new tcp_socket, ssl_socket }

        it 'closes the ssl socket' do
          expect(ssl_socket).to receive(:close)
          connection.close
        end

        it 'closes the tcp socket' do
          expect(tcp_socket).to receive(:close)
          connection.close
        end
      end

      describe '#write' do
        let(:connection) { APNSConnection.new tcp_socket, ssl_socket }
        let(:contents_string) { 'the contents string' }

        it 'writes the ssl socket' do
          expect(ssl_socket).to receive(:write).with contents_string
          connection.write contents_string
        end<commit_msg>Added parentheses to nested method call<commit_after>
module RubyPushNotifications
  module APNS
    describe APNSConnection do

      let(:cert) { File.read 'spec/support/dummy.pem' }
      let(:tcp_socket) { instance_double(TCPSocket).as_null_object }
      let(:ssl_socket) { instance_double(OpenSSL::SSL::SSLSocket).as_null_object }

      describe '::open' do
        before do
          allow(TCPSocket).to receive(:new).with('gateway.sandbox.push.apple.com', 2195).and_return tcp_socket
          allow(OpenSSL::SSL::SSLSocket).to receive(:new).with(tcp_socket, an_instance_of(OpenSSL::SSL::SSLContext)).and_return ssl_socket
        end

        it 'creates the connection' do
          expect(TCPSocket).to receive(:new).with('gateway.sandbox.push.apple.com', 2195).and_return tcp_socket
          expect(OpenSSL::SSL::SSLSocket).to receive(:new).with(tcp_socket, an_instance_of(OpenSSL::SSL::SSLContext)).and_return ssl_socket
          APNSConnection.open cert, true
        end

        it 'returns an instance of APNSConnection' do
          expect(APNSConnection.open(cert, true)).to be_a APNSConnection
        end

        it 'sets the password for pem file' do
          expect(OpenSSL::SSL::SSLSocket).to receive(:new).with(tcp_socket, an_instance_of(OpenSSL::SSL::SSLContext)).and_return ssl_socket
          expect(OpenSSL::PKey::RSA).to receive(:new).with(cert, 'password')
          expect(APNSConnection.open(cert, true, 'password')).to be_a APNSConnection
        end
      end

      describe '#close' do
        let(:connection) { APNSConnection.new tcp_socket, ssl_socket }

        it 'closes the ssl socket' do
          expect(ssl_socket).to receive(:close)
          connection.close
        end

        it 'closes the tcp socket' do
          expect(tcp_socket).to receive(:close)
          connection.close
        end
      end

      describe '#write' do
        let(:connection) { APNSConnection.new tcp_socket, ssl_socket }
        let(:contents_string) { 'the contents string' }

        it 'writes the ssl socket' do
          expect(ssl_socket).to receive(:write).with contents_string
          connection.write contents_string
        end
{'fraction_non_alphanumeric': 0.10572483841181902, 'fraction_numerical': 0.003693444136657433, 'mean_word_length': 3.0046210720887245, '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': '6886237', 'n_tokens_mistral': 1290, 'n_tokens_neox': 1256, 'n_words': 268}