Sha256: 6204252c13ec8f4ddaa4251ec24efb1c890d0ea879093b2c2c1b170590c85be2

Contents?: true

Size: 964 Bytes

Versions: 12

Compression:

Stored size: 964 Bytes

Contents

require 'functional_spec_helper'

describe 'WPNs' do
  let(:app) { Rpush::Wpns::App.new }
  let(:notification) { Rpush::Wpns::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.save!

    notification.app = app
    notification.uri = 'http://sn1.notify.live.net/'
    notification.alert = 'test'
    notification.save!

    Net::HTTP::Persistent.stub(new: http)
  end

  it 'delivers a notification successfully' do
    response.stub(to_hash: { 'x-notificationstatus' => ['Received'] })

    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)

    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

Version Path
rpush-2.2.0-java spec/functional/wpns_spec.rb
rpush-2.2.0 spec/functional/wpns_spec.rb
rpush-2.1.0-java spec/functional/wpns_spec.rb
rpush-2.1.0 spec/functional/wpns_spec.rb
rpush-2.0.1-java spec/functional/wpns_spec.rb
rpush-2.0.1 spec/functional/wpns_spec.rb
rpush-2.0.0-java spec/functional/wpns_spec.rb
rpush-2.0.0 spec/functional/wpns_spec.rb
rpush-2.0.0.rc1-java spec/functional/wpns_spec.rb
rpush-2.0.0.rc1 spec/functional/wpns_spec.rb
rpush-2.0.0.beta2 spec/functional/wpns_spec.rb
rpush-2.0.0.beta1 spec/functional/wpns_spec.rb