Sha256: 4aba4cf92e75f382cddf47e77c40e255cfcfc8b9b4d7660a7de06fe89fe68013

Contents?: true

Size: 1.26 KB

Versions: 1

Compression:

Stored size: 1.26 KB

Contents

require 'spec_helper'

describe Notifiable::Apns::Grocer::Stream do
  
  let(:g) { Notifiable::Apns::Grocer::Stream.new }
  let(:n) { Notifiable::Notification.create(:message => "Test message") }
  let(:d) { Notifiable::DeviceToken.create(:token => "ABC123", :provider => :apns) }
  let(:u) { User.new(d) }
  
  it "sends a single grocer notification" do    
    g.env = "test"      
    g.send_notification(n, d)
    
    Timeout.timeout(2) {
      notification = @grocer.notifications.pop
      notification.alert.should eql "Test message"
    }
  end
  
  it "sends a single grocer notification in a batch" do
    
    Notifiable.batch do |b|
      b.add(n, u)
    end
    Notifiable::NotificationDeviceToken.count.should == 1
    
    Timeout.timeout(2) {
      notification = @grocer.notifications.pop
      notification.alert.should eql "Test message"
    }
  end 
  
  it "supports custom properties" do
    n.params = {:flag => true}
    
    Notifiable.batch do |b|
      b.add(n, u)
    end
    Notifiable::NotificationDeviceToken.count.should == 1
    
    Timeout.timeout(2) {
      notification = @grocer.notifications.pop
      notification.custom[:flag].should == true
    }
  end
  
end

User = Struct.new(:device_token) do
  def device_tokens
    [device_token]
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
notifiable-apns-grocer-0.3.0 spec/grocer_spec.rb