Sha256: f573ad86f360f47070d0b01153ab1882f666f4c8798ea530e293e9389e572211
Contents?: true
Size: 1.04 KB
Versions: 12
Compression:
Stored size: 1.04 KB
Contents
require 'functional_spec_helper' describe 'GCM' do let(:app) { Rpush::Gcm::App.new } let(:notification) { Rpush::Gcm::Notification.new } let(:response) { double(Net::HTTPResponse, code: 200) } let(:http) { double(Net::HTTP::Persistent, request: response, shutdown: nil) } before do app.name = 'test' app.auth_key = 'abc123' app.save! notification.app_id = app.id notification.registration_ids = ['foo'] notification.data = { message: 'test' } notification.save! Net::HTTP::Persistent.stub(new: http) end it 'delivers a notification successfully' do response.stub(body: JSON.dump(results: [{ message_id: notification.registration_ids.first.to_s }])) expect do Rpush.push notification.reload end.to change(notification, :delivered).to(true) end it 'fails to deliver a notification successfully' do response.stub(body: JSON.dump(results: [{ error: 'Err' }])) expect do Rpush.push notification.reload end.to_not change(notification, :delivered).to(true) end end
Version data entries
12 entries across 12 versions & 1 rubygems