Sha256: 7905a85291b466ce9a0a47f2fccc9c0a85b28bca5c464474587fcff3270c9fdf

Contents?: true

Size: 1.27 KB

Versions: 34

Compression:

Stored size: 1.27 KB

Contents

require 'spec_helper'

describe Ably::Rest::Channel::PushChannel do
  subject { Ably::Rest::Channel::PushChannel }

  let(:channel_name) { 'unique' }
  let(:client) { double('client').as_null_object }
  let(:channel) { Ably::Rest::Channel.new(client, channel_name) }

  it 'is constructed with a channel' do
    expect(subject.new(channel)).to be_a(Ably::Rest::Channel::PushChannel)
  end

  it 'raises an exception if constructed with an invalid type' do
    expect { subject.new(Hash.new) }.to raise_error(ArgumentError)
  end

  it 'exposes the channel as attribute #channel' do
    expect(subject.new(channel).channel).to eql(channel)
  end

  it 'is available in the #push attribute of the channel' do
    expect(channel.push).to be_a(Ably::Rest::Channel::PushChannel)
    expect(channel.push.channel).to eql(channel)
  end

  context 'methods not implemented as push notifications' do
    subject { Ably::Rest::Channel::PushChannel.new(channel) }

    %w(subscribe_device subscribe_client_id unsubscribe_device unsubscribe_client_id get_subscriptions).each do |method_name|
      specify "##{method_name} raises an unsupported exception" do
        expect { subject.public_send(method_name, 'foo') }.to raise_error(Ably::Exceptions::PushNotificationsNotSupported)
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 2 rubygems

Version Path
ably-rest-1.1.5 lib/submodules/ably-ruby/spec/unit/rest/push_channel_spec.rb
ably-1.1.5 spec/unit/rest/push_channel_spec.rb
ably-rest-1.1.4 lib/submodules/ably-ruby/spec/unit/rest/push_channel_spec.rb
ably-1.1.4 spec/unit/rest/push_channel_spec.rb
ably-rest-1.1.4.rc lib/submodules/ably-ruby/spec/unit/rest/push_channel_spec.rb
ably-1.1.4.rc spec/unit/rest/push_channel_spec.rb
ably-rest-1.1.3 lib/submodules/ably-ruby/spec/unit/rest/push_channel_spec.rb
ably-1.1.3 spec/unit/rest/push_channel_spec.rb
ably-rest-1.1.2 lib/submodules/ably-ruby/spec/unit/rest/push_channel_spec.rb
ably-1.1.2 spec/unit/rest/push_channel_spec.rb
ably-rest-1.1.2.rc1 lib/submodules/ably-ruby/spec/unit/rest/push_channel_spec.rb
ably-1.1.1 spec/unit/rest/push_channel_spec.rb
ably-rest-1.1.0 lib/submodules/ably-ruby/spec/unit/rest/push_channel_spec.rb
ably-1.1.0 spec/unit/rest/push_channel_spec.rb