Sha256: 71c655cf77de63d0cd7a70d897aa82cbeb5b389c72d7a30ab7e921ec09a863ad

Contents?: true

Size: 1.24 KB

Versions: 2

Compression:

Stored size: 1.24 KB

Contents

require 'spec_helper'

describe DeviceCloud::PushNotification::Base 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,
      full_path: '/foo/bar/baz.json'
    )
  end

  subject { DeviceCloud::PushNotification::Base.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 "#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
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
device_cloud-0.0.5 spec/device_cloud/push_notification/base_spec.rb
device_cloud-0.0.4 spec/device_cloud/push_notification/base_spec.rb