Sha256: 7d76bb2587fb64ab0b28ddb7fa7c903e7625b81bb72452246d2069464b141bf2

Contents?: true

Size: 937 Bytes

Versions: 2

Compression:

Stored size: 937 Bytes

Contents

require 'unit_spec_helper'

describe Rpush::Daemon::Dispatcher::Http do
  let(:app) { double }
  let(:delivery_class) { double }
  let(:notification) { double }
  let(:batch) { double }
  let(:http) { double }
  let(:dispatcher) { Rpush::Daemon::Dispatcher::Http.new(app, delivery_class) }

  before { Net::HTTP::Persistent.stub(:new => http) }

  it 'constructs a new persistent connection' do
    Net::HTTP::Persistent.should_receive(:new)
    Rpush::Daemon::Dispatcher::Http.new(app, delivery_class)
  end

  describe 'dispatch' do
    it 'delivers the notification' do
      delivery = double
      delivery_class.should_receive(:new).with(app, http, notification, batch).and_return(delivery)
      delivery.should_receive(:perform)
      dispatcher.dispatch(notification, batch)
    end
  end

  describe 'cleanup' do
    it 'closes the connection' do
      http.should_receive(:shutdown)
      dispatcher.cleanup
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rpush-1.0.0-java spec/unit/daemon/dispatcher/http_spec.rb
rpush-1.0.0 spec/unit/daemon/dispatcher/http_spec.rb