Sha256: 7c9c4c6810c8ad823fb4e53f1be3aa69aa81a2411bfc18e1b893c905025bf6fa

Contents?: true

Size: 1.46 KB

Versions: 2

Compression:

Stored size: 1.46 KB

Contents

require 'spec_helper'

describe DeviceCloud::PushNotification::BaseNotification do
  let(:data) do
    {
      'id' => '1234',
      'device_id' => 'm:1392301029',
      'type' => 'some type',
      'queued_dt' => '2013-06-24T14:52:55.421Z',
      'value' => {'this' => 'is a value'}
    }
  end
  let(:file_data) do
    OpenStruct.new(
      full_path: '/some/place/file_name.json',
      data: data,
      file_name: 'file_name.json'
    )
  end

  subject { DeviceCloud::PushNotification::BaseNotification.new file_data }

  describe "attributes" do
    its(:id) { should eq data['id'] }
    its(:full_path) { should eq file_data.full_path }
    its(:device_id) { should eq data['device_id'] }
    its(:type) { should eq data['type'] }
    its(:queued_at) { should eq data['queued_dt'] }
    its(:value) { should eq data['value'] }
  end

  describe "#data" do
    its(:data) { should eq file_data.data }
  end

  describe "#handle!" do
    it "should raise NotImplementedError" do
      expect{subject.handle!}.to raise_error NotImplementedError
    end
  end

  describe "#mac_address" do
    context "when device_id present" do
      its(:mac_address) { should eq('13:92:30:10:29') }
    end

    context 'when device_id blank' do
      before(:each) do
        data['device_id'] = ''
      end

      its(:mac_address) { should eq '' }
    end
  end

  describe "#file_name" do
    context 'when id is present' do
      its(:file_name) { should eq file_data.file_name}
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
device_cloud-0.0.11 spec/device_cloud/push_notification/base_notification_spec.rb
device_cloud-0.0.10 spec/device_cloud/push_notification/base_notification_spec.rb