spec/acceptance/rest/channel_spec.rb in ably-0.8.4 vs spec/acceptance/rest/channel_spec.rb in ably-0.8.5

- old
+ new

@@ -10,13 +10,14 @@ let(:client) do Ably::Rest::Client.new(client_options) end describe '#publish' do - let(:channel) { client.channel(random_str) } - let(:name) { 'foo' } - let(:data) { 'woop!' } + let(:channel_name) { random_str } + let(:channel) { client.channel(channel_name) } + let(:name) { 'foo' } + let(:data) { 'woop!' } context 'with name and data arguments' do it 'publishes the message and return true indicating success' do expect(channel.publish(name, data)).to eql(true) expect(channel.history.items.first.name).to eql(name) @@ -28,9 +29,27 @@ it 'publishes the message with the attributes and return true indicating success' do expect(channel.publish(name, data, client_id: client_id)).to eql(true) expect(channel.history.items.first.client_id).to eql(client_id) end + end + end + + context 'with a client_id configured in the ClientOptions' do + let(:client_id) { random_str } + let(:client_options) { default_options.merge(client_id: client_id) } + + it 'publishes the message without a client_id' do + expect(client).to receive(:post). + with("/channels/#{channel_name}/publish", hash_excluding(client_id: client_id)). + and_return(double('response', status: 201)) + + expect(channel.publish(name, data)).to eql(true) + end + + it 'expects a client_id to be added by the realtime service' do + channel.publish name, data + expect(channel.history.items.first.client_id).to eql(client_id) end end context 'with an array of Hash objects with :name and :data attributes' do let(:messages) do