lib/submodules/ably-ruby/spec/acceptance/rest/presence_spec.rb in ably-rest-0.8.14 vs lib/submodules/ably-ruby/spec/acceptance/rest/presence_spec.rb in ably-rest-0.8.15

- old
+ new

@@ -67,18 +67,16 @@ { limit: 100 } end let(:endpoint) do - client.endpoint.tap do |client_end_point| - client_end_point.user = key_name - client_end_point.password = key_secret - end + 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) } @@ -180,14 +178,11 @@ let(:channel_name) { "persisted:#{random_str(4)}" } let(:presence) { client.channel(channel_name).presence } let(:user) { 'appid.keyuid' } let(:secret) { random_str(8) } let(:endpoint) do - client.endpoint.tap do |client_end_point| - client_end_point.user = user - client_end_point.password = secret - end + client.endpoint end let(:client) do Ably::Rest::Client.new(key: "#{user}:#{secret}") end let(:history_options) do @@ -199,10 +194,11 @@ 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) @@ -239,10 +235,11 @@ } } 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) @@ -308,14 +305,11 @@ describe 'decoding permutations using mocked #history', :webmock do let(:user) { 'appid.keyuid' } let(:secret) { random_str(8) } let(:endpoint) do - client.endpoint.tap do |client_end_point| - client_end_point.user = user - client_end_point.password = secret - end + client.endpoint end let(:client) do Ably::Rest::Client.new(client_options.merge(key: "#{user}:#{secret}")) end @@ -346,10 +340,11 @@ 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 @@ -363,10 +358,11 @@ 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 @@ -393,10 +389,11 @@ 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 @@ -417,9 +414,10 @@ 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