spec/acceptance/rest/channel_spec.rb in ably-1.1.6 vs spec/acceptance/rest/channel_spec.rb in ably-1.1.7
- old
+ new
@@ -58,10 +58,12 @@
{ name: index.to_s, data: { "index" => index + 10 } }
end
end
it 'publishes an array of messages in one HTTP request' do
+ expect(messages.sum(&:size) < Ably::Rest::Channel::MAX_MESSAGE_SIZE).to eq(true)
+
expect(client).to receive(:post).once.and_call_original
expect(channel.publish(messages)).to eql(true)
expect(channel.history.items.map(&:name)).to match_array(messages.map { |message| message[:name] })
expect(channel.history.items.map(&:data)).to match_array(messages.map { |message| message[:data] })
end
@@ -73,10 +75,12 @@
Ably::Models::Message(name: index.to_s, data: { "index" => index + 10 })
end
end
it 'publishes an array of messages in one HTTP request' do
+ expect(messages.sum(&:size) < Ably::Rest::Channel::MAX_MESSAGE_SIZE).to eq(true)
+
expect(client).to receive(:post).once.and_call_original
expect(channel.publish(messages)).to eql(true)
expect(channel.history.items.map(&:name)).to match_array(messages.map(&:name))
expect(channel.history.items.map(&:data)).to match_array(messages.map(&:data))
end
@@ -346,9 +350,18 @@
channel.history do |messages|
expect(messages.length).to eql(2)
expect(messages.first.data).to eql(payload)
expect(messages.last.data).to eql(payload)
end
+ end
+ end
+
+ context 'message size is exceeded (#TO3l8)' do
+ let(:data) { 101.times.map { { data: 'x' * 655 } } }
+
+ it 'should raise Ably::Exceptions::MaxMessageSizeExceeded exception' do
+ expect { channel.publish([ data: data ]) }.to \
+ raise_error(Ably::Exceptions::MaxMessageSizeExceeded)
end
end
end
describe '#history' do