Sha256: e8e7bbd05a0a418d501829ce3df9db84d03878be3af5f461fa523278e87d8136
Contents?: true
Size: 1.6 KB
Versions: 2
Compression:
Stored size: 1.6 KB
Contents
require 'unit_spec_helper' describe 'APNs' do let(:app) { Rpush::Apns::App.new } let(:notification) { Rpush::Apns::Notification.new } let(:tcp_socket) { double(TCPSocket, setsockopt: nil, close: nil) } let(:ssl_socket) { double(OpenSSL::SSL::SSLSocket, :sync= => nil, connect: nil, write: nil, flush: nil, read: nil, close: nil) } before do app.certificate = TEST_CERT app.name = 'test' app.environment = 'sandbox' app.save! notification.app = app notification.alert = 'test' notification.device_token = 'a' * 64 notification.save! Rails.stub(root: File.expand_path(File.join(File.dirname(__FILE__), '..', 'tmp'))) Rpush.config.logger = ::Logger.new(STDOUT) stub_tcp_connection end def stub_tcp_connection TCPSocket.stub(:new => tcp_socket) OpenSSL::SSL::SSLSocket.stub(:new => ssl_socket) IO.stub(:select => nil) end it 'delivers a notification successfully' do expect do Rpush.push notification.reload end.to change(notification, :delivered).to(true) end it 'fails to deliver a notification successfully' do IO.stub(:select => true) ssl_socket.stub(:read => [8, 4, 69].pack('ccN')) expect do Rpush.push notification.reload end.to_not change(notification, :delivered).to(true) end it 'receives feedback' do tuple = "N\xE3\x84\r\x00 \x83OxfU\xEB\x9F\x84aJ\x05\xAD}\x00\xAF1\xE5\xCF\xE9:\xC3\xEA\a\x8F\x1D\xA4M*N\xB0\xCE\x17" allow(ssl_socket).to receive(:read).and_return(tuple, nil) expect do Rpush.apns_feedback end.to change(Rpush::Apns::Feedback, :count).to(1) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rpush-1.0.0-java | spec/functional/apns_spec.rb |
rpush-1.0.0 | spec/functional/apns_spec.rb |