Sha256: 66b5e3df6c54f6886a6491ba3e5a64c765d38ae6ca2470150c723277a4112775

Contents?: true

Size: 1.8 KB

Versions: 2

Compression:

Stored size: 1.8 KB

Contents

require 'spec_helper'

describe FiveMobilePush::Client do

  let(:application_uid) { 'nulayer' }
  let(:api_token) { 'token_123' }

  subject { FiveMobilePush::Client.new :api_token => api_token, :application_uid => application_uid }

  describe "#device" do

    it "initializes a Device" do
      subject.device('abc').should be_kind_of(FiveMobilePush::Device)
    end

  end

  describe "#notifier" do

    it "initializes a Notifier" do
      subject.notifier.should be_kind_of(FiveMobilePush::Notifier)
    end

  end

  describe "#tag" do

    it "initializes a Tag" do
      subject.tag('device-uid').should be_kind_of(FiveMobilePush::Tag)
    end

  end

  context "response code is 400" do

    let(:path) { (described_class::DEFAULT_ENDPOINT + "/some_endpoint?api_token=#{api_token}&application_id=#{application_uid}").to_s }

    it "raises a GeneralError" do
      stub_request(:any, path).to_return(:body => "something broken", :status => 400)
      expect { subject.get(path) }.to raise_error(FiveMobilePush::GeneralError)
    end

  end

  context "response code is 401" do

    let(:path) { (described_class::DEFAULT_ENDPOINT + "/some_endpoint?api_token=#{api_token}&application_id=#{application_uid}").to_s }

    it "raises a GeneralError" do
      stub_request(:any, path).to_return(:body => "something broken", :status => 401)
      expect { subject.get(path) }.to raise_error(FiveMobilePush::UnauthorizedError)
    end

  end

  context "response code is 500" do

    let(:path) { (described_class::DEFAULT_ENDPOINT + "/some_endpoint?api_token=#{api_token}&application_id=#{application_uid}").to_s }

    it "raises a GeneralError" do
      stub_request(:any, path).to_return(:body => "something broken", :status => 500)
      expect { subject.get(path) }.to raise_error(FiveMobilePush::ServerError)
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
five_mobile_push-0.4.7 spec/five_mobile_push/client_spec.rb
five_mobile_push-0.4.6 spec/five_mobile_push/client_spec.rb