spec/acceptance/rest/message_spec.rb in ably-0.7.5 vs spec/acceptance/rest/message_spec.rb in ably-0.7.6
- old
+ new
@@ -4,22 +4,22 @@
describe Ably::Rest::Channel, 'messages' do
include Ably::Modules::Conversions
vary_by_protocol do
- let(:default_client_options) { { api_key: api_key, environment: environment, protocol: protocol } }
+ let(:default_client_options) { { key: api_key, environment: environment, protocol: protocol } }
let(:client_options) { default_client_options }
let(:client) { Ably::Rest::Client.new(client_options) }
let(:other_client) { Ably::Rest::Client.new(client_options) }
let(:channel) { client.channel('test') }
context 'publishing with an ASCII_8BIT message name' do
let(:message_name) { random_str.encode(Encoding::ASCII_8BIT) }
it 'is converted into UTF_8' do
channel.publish message_name, 'example'
- message = channel.history.first
+ message = channel.history.items.first
expect(message.name.encoding).to eql(Encoding::UTF_8)
expect(message.name.encode(Encoding::ASCII_8BIT)).to eql(message_name)
end
end
@@ -78,17 +78,17 @@
end
it 'sends and retrieves messages that are encrypted & decrypted by the Ably library' do
encrypted_channel.publish 'example', encoded_data_decoded
- message = encrypted_channel.history.first
+ message = encrypted_channel.history.items.first
expect(message.data).to eql(encoded_data_decoded)
expect(message.encoding).to be_nil
end
end
- resources_root = File.expand_path('../../../resources', __FILE__)
+ resources_root = File.expand_path('../../../../lib/submodules/ably-common/test-resources', __FILE__)
def self.add_tests_for_data(data)
data['items'].each_with_index do |item, index|
context "item #{index} with encrypted encoding #{item['encrypted']['encoding']}" do
it_behaves_like 'an Ably encrypter and decrypter', item, data
@@ -113,11 +113,11 @@
it 'encrypts on #publish and decrypts on #history' do
message_count.times do |index|
encrypted_channel.publish index.to_s, "#{index}-#{data}"
end
- messages = encrypted_channel.history
+ messages = encrypted_channel.history.items
expect(messages.count).to eql(message_count)
messages.each do |message|
expect(message.data).to eql("#{message.name}-#{data}")
expect(message.encoding).to be_nil
@@ -138,11 +138,11 @@
payload_description = "#{payload.class}#{" #{payload.encoding}" if payload.kind_of?(String)}"
specify "delivers a #{payload_description} payload to the receiver" do
encrypted_channel.publish 'example', payload
- message = other_client_channel.history.first
+ message = other_client_channel.history.items.first
expect(message.data).to eql(payload)
expect(message.encoding).to be_nil
end
end
end
@@ -154,11 +154,11 @@
let(:payload) { MessagePack.pack({ 'key' => random_str }) }
it 'does not attempt to decrypt the message' do
unencrypted_channel.publish 'example', payload
- message = other_client_encrypted_channel.history.first
+ message = other_client_encrypted_channel.history.items.first
expect(message.data).to eql(payload)
expect(message.encoding).to be_nil
end
end
@@ -173,11 +173,11 @@
before do
encrypted_channel.publish 'example', payload
end
it 'retrieves the message that remains encrypted with an encrypted encoding attribute' do
- message = other_client_unencrypted_channel.history.first
+ message = other_client_unencrypted_channel.history.items.first
expect(message.data).to_not eql(payload)
expect(message.encoding).to match(/^cipher\+aes-256-cbc/)
end
it 'logs a Cipher exception' do
@@ -200,11 +200,11 @@
before do
encrypted_channel_client1.publish 'example', payload
end
it 'retrieves the message that remains encrypted with an encrypted encoding attribute' do
- message = encrypted_channel_client2.history.first
+ message = encrypted_channel_client2.history.items.first
expect(message.data).to_not eql(payload)
expect(message.encoding).to match(/^cipher\+aes-256-cbc/)
end
it 'logs a Cipher exception' do
@@ -227,10 +227,10 @@
before do
encrypted_channel_client1.publish 'example', payload
end
it 'retrieves the message that remains encrypted with an encrypted encoding attribute' do
- message = encrypted_channel_client2.history.first
+ message = encrypted_channel_client2.history.items.first
expect(message.data).to_not eql(payload)
expect(message.encoding).to match(/^cipher\+aes-256-cbc/)
end
it 'logs a Cipher exception' do