lib/submodules/ably-ruby/spec/acceptance/rest/client_spec.rb in ably-rest-0.9.0 vs lib/submodules/ably-ruby/spec/acceptance/rest/client_spec.rb in ably-rest-0.9.1

- old
+ new

@@ -109,11 +109,11 @@ context 'with basic auth', webmock: true do let(:client_options) { default_options.merge(key: api_key) } let!(:get_message_history_stub) do - stub_request(:get, "https://#{api_key}@#{environment}-#{Ably::Rest::Client::DOMAIN}/channels/#{channel_name}/messages?#{history_querystring}"). + stub_request(:get, "https://#{environment}-#{Ably::Rest::Client::DOMAIN}/channels/#{channel_name}/messages?#{history_querystring}"). to_return(body: [], headers: { 'Content-Type' => 'application/json' }) end it 'sends the API key in authentication part of the secure URL (the Authorization: Basic header is not used with the Faraday HTTP library by default)' do client.channel(channel_name).history history_params @@ -282,11 +282,11 @@ end context 'when environment is NOT production' do let(:client_options) { default_options.merge(environment: 'sandbox', key: api_key) } let!(:default_host_request_stub) do - stub_request(:post, "https://#{api_key}@#{environment}-#{Ably::Rest::Client::DOMAIN}#{path}").to_return do + stub_request(:post, "https://#{environment}-#{Ably::Rest::Client::DOMAIN}#{path}").to_return do raise Faraday::TimeoutError.new('timeout error message') end end it 'does not retry failed requests with fallback hosts when there is a connection error' do @@ -311,20 +311,20 @@ before do stub_const 'Ably::FALLBACK_HOSTS', custom_hosts end let!(:first_fallback_request_stub) do - stub_request(:post, "https://#{api_key}@#{custom_hosts[0]}#{path}").to_return(&fallback_block) + stub_request(:post, "https://#{custom_hosts[0]}#{path}").to_return(&fallback_block) end let!(:second_fallback_request_stub) do - stub_request(:post, "https://#{api_key}@#{custom_hosts[1]}#{path}").to_return(&fallback_block) + stub_request(:post, "https://#{custom_hosts[1]}#{path}").to_return(&fallback_block) end context 'and connection times out' do let!(:default_host_request_stub) do - stub_request(:post, "https://#{api_key}@#{Ably::Rest::Client::DOMAIN}#{path}").to_return do + stub_request(:post, "https://#{Ably::Rest::Client::DOMAIN}#{path}").to_return do raise Faraday::TimeoutError.new('timeout error message') end end it "tries fallback hosts #{http_defaults.fetch(:max_retry_count)} times" do @@ -334,11 +334,11 @@ expect(second_fallback_request_stub).to have_been_requested end context "and the total request time exeeds #{http_defaults.fetch(:max_retry_duration)} seconds" do let!(:default_host_request_stub) do - stub_request(:post, "https://#{api_key}@#{Ably::Rest::Client::DOMAIN}#{path}").to_return do + stub_request(:post, "https://#{Ably::Rest::Client::DOMAIN}#{path}").to_return do sleep max_retry_duration * 1.5 raise Faraday::TimeoutError.new('timeout error message') end end @@ -351,11 +351,11 @@ end end context 'and connection fails' do let!(:default_host_request_stub) do - stub_request(:post, "https://#{api_key}@#{Ably::Rest::Client::DOMAIN}#{path}").to_return do + stub_request(:post, "https://#{Ably::Rest::Client::DOMAIN}#{path}").to_return do raise Faraday::ConnectionFailed.new('connection failure error message') end end it "tries fallback hosts #{http_defaults.fetch(:max_retry_count)} times" do @@ -367,11 +367,11 @@ end context 'and basic authentication fails' do let(:status) { 401 } let!(:default_host_request_stub) do - stub_request(:post, "https://#{api_key}@#{Ably::Rest::Client::DOMAIN}#{path}").to_return( + stub_request(:post, "https://#{Ably::Rest::Client::DOMAIN}#{path}").to_return( headers: { 'Content-Type' => 'application/json' }, status: status, body: { "error" => { "statusCode" => 401, @@ -399,11 +399,11 @@ status: status } end end let!(:default_host_request_stub) do - stub_request(:post, "https://#{api_key}@#{Ably::Rest::Client::DOMAIN}#{path}").to_return(&fallback_block) + stub_request(:post, "https://#{Ably::Rest::Client::DOMAIN}#{path}").to_return(&fallback_block) end it 'attempts the fallback hosts as this is an authentication failure' do expect { publish_block.call }.to raise_error(Ably::Exceptions::ServerError) expect(default_host_request_stub).to have_been_requested @@ -435,20 +435,20 @@ status: status } end end let!(:default_host_request_stub) do - stub_request(:post, "https://#{api_key}@#{Ably::Rest::Client::DOMAIN}#{path}").to_return(&fallback_block) + stub_request(:post, "https://#{Ably::Rest::Client::DOMAIN}#{path}").to_return(&fallback_block) end context 'with custom fallback hosts provided' do let!(:first_fallback_request_stub) do - stub_request(:post, "https://#{api_key}@#{custom_hosts[0]}#{path}").to_return(&fallback_block) + stub_request(:post, "https://#{custom_hosts[0]}#{path}").to_return(&fallback_block) end let!(:second_fallback_request_stub) do - stub_request(:post, "https://#{api_key}@#{custom_hosts[1]}#{path}").to_return(&fallback_block) + stub_request(:post, "https://#{custom_hosts[1]}#{path}").to_return(&fallback_block) end let(:client_options) { production_options.merge(fallback_hosts: custom_hosts) } @@ -617,20 +617,20 @@ status: status } end end let!(:default_host_request_stub) do - stub_request(:post, "https://#{api_key}@#{env}-#{Ably::Rest::Client::DOMAIN}#{path}").to_return(&fallback_block) + stub_request(:post, "https://#{env}-#{Ably::Rest::Client::DOMAIN}#{path}").to_return(&fallback_block) end context 'with custom fallback hosts provided (#RSC15b, #TO3k6)' do let!(:first_fallback_request_stub) do - stub_request(:post, "https://#{api_key}@#{custom_hosts[0]}#{path}").to_return(&fallback_block) + stub_request(:post, "https://#{custom_hosts[0]}#{path}").to_return(&fallback_block) end let!(:second_fallback_request_stub) do - stub_request(:post, "https://#{api_key}@#{custom_hosts[1]}#{path}").to_return(&fallback_block) + stub_request(:post, "https://#{custom_hosts[1]}#{path}").to_return(&fallback_block) end let(:client_options) { production_options.merge(fallback_hosts: custom_hosts) } @@ -664,15 +664,15 @@ let(:client_options) { production_options.merge(fallback_hosts_use_default: true) } let!(:first_fallback_request_stub) do - stub_request(:post, "https://#{api_key}@#{Ably::FALLBACK_HOSTS[0]}#{path}").to_return(&fallback_block) + stub_request(:post, "https://#{Ably::FALLBACK_HOSTS[0]}#{path}").to_return(&fallback_block) end let!(:second_fallback_request_stub) do - stub_request(:post, "https://#{api_key}@#{Ably::FALLBACK_HOSTS[1]}#{path}").to_return(&fallback_block) + stub_request(:post, "https://#{Ably::FALLBACK_HOSTS[1]}#{path}").to_return(&fallback_block) end let(:client_options) { production_options.merge(fallback_hosts: custom_hosts) } @@ -699,11 +699,11 @@ context 'fallback hosts', :webmock do let(:path) { '/channels/test/publish' } let!(:custom_host_request_stub) do - stub_request(:post, "https://#{api_key}@#{custom_host}#{path}").to_return do + stub_request(:post, "https://#{custom_host}#{path}").to_return do raise Faraday::ConnectionFailed.new('connection failure error message') end end before do @@ -838,11 +838,11 @@ lib = ['ruby'] lib << variant if variant lib << Ably::VERSION - stub_request(:post, "#{client.endpoint.to_s.gsub('://', "://#{api_key}@")}/channels/foo/publish"). + stub_request(:post, "#{client.endpoint}/channels/foo/publish"). with(headers: { 'X-Ably-Version' => Ably::PROTOCOL_VERSION, 'X-Ably-Lib' => lib.join('-') }). to_return(status: 201, body: '{}', headers: { 'Content-Type' => 'application/json' }) @@ -879,10 +879,10 @@ context 'paged results' do let(:channel_name) { random_str } it 'provides paging' do 10.times do - client.request(:post, "/channels/#{channel_name}/publish", {}, { 'name': 'test' }) + client.request(:post, "/channels/#{channel_name}/publish", {}, { 'name' => 'test' }) end response = client.request(:get, "/channels/#{channel_name}/messages", { limit: 2 }) expect(response.items.length).to eql(2) expect(response).to be_has_next next_page = response.next