spec/acceptance/rest/message_spec.rb in ably-1.1.0 vs spec/acceptance/rest/message_spec.rb in ably-1.1.1

- old
+ new

@@ -118,22 +118,18 @@ context 'when ID is included (#RSL1k2, #RSL1k5)' do context 'with Message object' do let(:message) { Ably::Models::Message.new(id: id, data: data) } specify 'three REST publishes result in only one message being published' do - pending 'idempotency rolled out to global cluster' - 3.times { channel.publish [message] } expect(channel.history.items.length).to eql(1) expect(channel.history.items[0].id).to eql(id) end end context 'with #publish arguments only' do it 'three REST publishes result in only one message being published' do - pending 'idempotency rolled out to global cluster' - 3.times { channel.publish 'event', data, id: id } expect(channel.history.items.length).to eql(1) end end @@ -141,25 +137,21 @@ channel.publish 'event', data, id: id expect(channel.history.items[0].id).to eql(id) end specify 'for multiple messages in one publish operation (#RSL1k3)' do - pending 'idempotency rolled out to global cluster' - message_arr = 3.times.map { Ably::Models::Message.new(id: id, data: data) } expect { channel.publish message_arr }.to raise_error do |error| expect(error.code).to eql(40031) # Invalid publish request (invalid client-specified id), see https://github.com/ably/ably-common/pull/30 end end specify 'for multiple messages in one publish operation with IDs following the required format described in RSL1k1 (#RSL1k3)' do - pending 'idempotency rolled out to global cluster' - message_arr = 3.times.map { |index| Ably::Models::Message.new(id: "#{id}:#{index}", data: data) } channel.publish message_arr - expect(channel.history.items[0].id).to eql("{id}:0") - expect(channel.history.items[2].id).to eql("{id}:2") + expect(channel.history.items[2].id).to eql("#{id}:0") + expect(channel.history.items[0].id).to eql("#{id}:2") expect(channel.history.items.length).to eql(3) end end specify 'idempotent publishing is disabled by default with 1.1 (#TO3n)' do @@ -172,11 +164,11 @@ client = Ably::Rest::Client.new(key: api_key, protocol: protocol) expect(client.idempotent_rest_publishing).to be_truthy end context 'when idempotent publishing is enabled in the client library ClientOptions (#TO3n)' do - let(:client_options) { default_client_options.merge(idempotent_rest_publishing: true, log_level: :error) } + let(:client_options) { default_client_options.merge(idempotent_rest_publishing: true, log_level: :error, fallback_hosts: ["#{environment}-realtime.ably.io"]) } context 'when there is a network failure triggering an automatic retry (#RSL1k4)' do def mock_for_two_publish_failures @failed_http_posts = 0 allow(client).to receive(:can_fallback_to_alternate_ably_host?).and_return(true) @@ -193,24 +185,20 @@ context 'with Message object' do let(:message) { Ably::Models::Message.new(data: data) } before { mock_for_two_publish_failures } specify 'two REST publish retries result in only one message being published' do - pending 'idempotency rolled out to global cluster' - channel.publish [message] expect(channel.history.items.length).to eql(1) expect(@failed_http_posts).to eql(2) end end context 'with #publish arguments only' do before { mock_for_two_publish_failures } specify 'two REST publish retries result in only one message being published' do - pending 'idempotency rolled out to global cluster' - channel.publish 'event', data expect(channel.history.items.length).to eql(1) expect(@failed_http_posts).to eql(2) end end @@ -219,25 +207,21 @@ let(:id) { random_str } before { mock_for_two_publish_failures } specify 'two REST publish retries result in only one message being published' do - pending 'idempotency rolled out to global cluster' - channel.publish 'event', data, id: id expect(channel.history.items.length).to eql(1) expect(channel.history.items[0].id).to eql(id) expect(@failed_http_posts).to eql(2) end end specify 'for multiple messages in one publish operation' do - pending 'idempotency rolled out to global cluster' - message_arr = 3.times.map { Ably::Models::Message.new(data: data) } 3.times { channel.publish message_arr } - expect(channel.history.items.length).to eql(message_arr.length) + expect(channel.history.items.length).to eql(message_arr.length * 3) end end specify 'the ID is populated with a random ID and serial 0 from this lib (#RSL1k1)' do channel.publish 'event' @@ -246,16 +230,14 @@ expect(Base64.decode64(base_64_id).length).to eql(9) end context 'when publishing a batch of messages' do specify 'the ID is populated with a single random ID and sequence of serials from this lib (#RSL1k1)' do - pending 'idempotency rolled out to global cluster' - message = { name: 'event' } channel.publish [message, message, message] - expect(channel.history.items[0].length).to eql(3) - expect(channel.history.items[0].id).to match(/^[A-Za-z0-9\+\/]+:0$/) - expect(channel.history.items[2].id).to match(/^[A-Za-z0-9\+\/]+:2$/) + expect(channel.history.items.length).to eql(3) + expect(channel.history.items[0].id).to match(/^[A-Za-z0-9\+\/]+:2$/) + expect(channel.history.items[2].id).to match(/^[A-Za-z0-9\+\/]+:0$/) base_64_id = channel.history.items[0].id.split(':')[0] expect(Base64.decode64(base_64_id).length).to eql(9) end end end