spec/acceptance/rest/presence_spec.rb in ably-0.8.15 vs spec/acceptance/rest/presence_spec.rb in ably-1.0.0

- old
+ new

@@ -72,11 +72,10 @@ client.endpoint end let!(:get_stub) { query_params = query_options.map { |k, v| "#{k}=#{v}" }.join('&') stub_request(:get, "#{endpoint}/channels/#{Addressable::URI.encode(channel_name)}/presence?#{query_params}"). - with(basic_auth: [key_name, key_secret]). to_return(:body => '{}', :headers => { 'Content-Type' => 'application/json' }) } let(:channel_name) { random_str } let(:channel) { client.channels.get(channel_name) } @@ -194,11 +193,10 @@ context 'limit options', :webmock do let!(:history_stub) { query_params = history_options.map { |k, v| "#{k}=#{v}" }.join('&') stub_request(:get, "#{endpoint}/channels/#{Addressable::URI.encode(channel_name)}/presence/history?#{query_params}"). - with(basic_auth: [user, secret]). to_return(:body => '{}', :headers => { 'Content-Type' => 'application/json' }) } before do presence.history(history_options) @@ -235,11 +233,10 @@ } } let!(:history_stub) { query_params = history_options.map { |k, v| "#{k}=#{v}" }.join('&') stub_request(:get, "#{endpoint}/channels/#{Addressable::URI.encode(channel_name)}/presence/history?#{query_params}"). - with(basic_auth: [user, secret]). to_return(:body => '{}', :headers => { 'Content-Type' => 'application/json' }) } before do presence.history(history_options) @@ -340,11 +337,10 @@ end context '#get' do let!(:get_stub) { stub_request(:get, "#{endpoint}/channels/#{Addressable::URI.encode(channel_name)}/presence?limit=100"). - with(basic_auth: [user, secret]). to_return(:body => serialized_encoded_message, :headers => { 'Content-Type' => content_type }) } after do expect(get_stub).to have_been_requested @@ -358,11 +354,10 @@ end context '#history' do let!(:history_stub) { stub_request(:get, "#{endpoint}/channels/#{Addressable::URI.encode(channel_name)}/presence/history?direction=backwards&limit=100"). - with(basic_auth: [user, secret]). to_return(:body => serialized_encoded_message, :headers => { 'Content-Type' => content_type }) } after do expect(history_stub).to have_been_requested @@ -389,11 +384,10 @@ context '#get' do let(:client_options) { default_options.merge(log_level: :fatal) } let!(:get_stub) { stub_request(:get, "#{endpoint}/channels/#{Addressable::URI.encode(channel_name)}/presence?limit=100"). - with(basic_auth: [user, secret]). to_return(:body => serialized_encoded_message_with_invalid_encoding, :headers => { 'Content-Type' => content_type }) } let(:presence_message) { presence.get.items.first } after do @@ -403,22 +397,21 @@ it 'returns the messages still encoded' do expect(presence_message.encoding).to match(/cipher\+aes-128-cbc/) end it 'logs a cipher error' do - expect(client.logger).to receive(:error) do |message| - expect(message).to match(/Cipher algorithm [\w-]+ does not match/) + expect(client.logger).to receive(:error) do |*args, &block| + expect(args.concat([block ? block.call : nil]).join(',')).to match(/Cipher algorithm [\w-]+ does not match/) end presence.get end end context '#history' do let(:client_options) { default_options.merge(log_level: :fatal) } let!(:history_stub) { stub_request(:get, "#{endpoint}/channels/#{Addressable::URI.encode(channel_name)}/presence/history?direction=backwards&limit=100"). - with(basic_auth: [user, secret]). to_return(:body => serialized_encoded_message_with_invalid_encoding, :headers => { 'Content-Type' => content_type }) } let(:presence_message) { presence.history.items.first } after do @@ -428,11 +421,11 @@ it 'returns the messages still encoded' do expect(presence_message.encoding).to match(/cipher\+aes-128-cbc/) end it 'logs a cipher error' do - expect(client.logger).to receive(:error) do |message| - expect(message).to match(/Cipher algorithm [\w-]+ does not match/) + expect(client.logger).to receive(:error) do |*args, &block| + expect(args.concat([block ? block.call : nil]).join(',')).to match(/Cipher algorithm [\w-]+ does not match/) end presence.history end end end