Sha256: ea5e4d7a0ad7aab82e793b3f8dffa5ad55bb1c9d429f9f6f67a22616b2bae0d7
Contents?: true
Size: 1.11 KB
Versions: 12
Compression:
Stored size: 1.11 KB
Contents
require 'functional_spec_helper' describe 'ADM' do let(:app) { Rpush::Adm::App.new } let(:notification) { Rpush::Adm::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.client_id = 'abc' app.client_secret = '123' app.save! notification.app = app 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(registrationID: 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(code: 400, body: JSON.dump(reason: 'error', registrationID: notification.registration_ids.first.to_s)) 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