@@ -139,7 +139,7 @@ def encode64(text)
139139 let ( :client_options ) { default_options . merge ( key : api_key , client_id : client_id ) }
140140
141141 let! ( :get_message_history_stub ) do
142- stub_request ( :get , "https://#{ environment } - #{ Ably :: Rest :: Client :: DOMAIN } /channels/#{ channel_name } /messages?#{ history_querystring } " )
142+ stub_request ( :get , "https://#{ client . hostname } /channels/#{ channel_name } /messages?#{ history_querystring } " )
143143 . with ( headers : { 'X-Ably-ClientId' => encode64 ( client_id ) } )
144144 . to_return ( body : [ ] , headers : { 'Content-Type' => 'application/json' } )
145145 end
@@ -155,7 +155,7 @@ def encode64(text)
155155 let ( :client_options ) { default_options . merge ( token : token_string ) }
156156
157157 let! ( :get_message_history_stub ) do
158- stub_request ( :get , "#{ http_protocol } ://#{ environment } - #{ Ably :: Rest :: Client :: DOMAIN } /channels/#{ channel_name } /messages?#{ history_querystring } " ) .
158+ stub_request ( :get , "#{ http_protocol } ://#{ client . hostname } /channels/#{ channel_name } /messages?#{ history_querystring } " ) .
159159 with ( headers : { 'Authorization' => "Bearer #{ encode64 ( token_string ) } " } ) .
160160 to_return ( body : [ ] , headers : { 'Content-Type' => 'application/json' } )
161161 end
@@ -312,9 +312,9 @@ def encode64(text)
312312
313313 context 'when environment is NOT production (#RSC15b)' do
314314 context 'and custom fallback hosts are empty' do
315- let ( :client_options ) { default_options . merge ( environment : 'sandbox' , key : api_key , fallback_hosts : [ ] ) }
315+ let ( :client_options ) { default_options . merge ( environment : 'nonprod: sandbox' , key : api_key , fallback_hosts : [ ] ) }
316316 let! ( :default_host_request_stub ) do
317- stub_request ( :post , "https://#{ environment } - #{ Ably :: Rest :: Client :: DOMAIN } #{ path } " ) . to_return do
317+ stub_request ( :post , "https://#{ client . hostname } #{ path } " ) . to_return do
318318 raise Faraday ::TimeoutError . new ( 'timeout error message' )
319319 end
320320 end
@@ -325,7 +325,7 @@ def encode64(text)
325325 end
326326
327327 context 'and no custom fallback hosts are provided' do
328- let ( :client_options ) { default_options . merge ( environment : 'sandbox' , key : api_key ) }
328+ let ( :client_options ) { default_options . merge ( environment : 'nonprod: sandbox' , key : api_key ) }
329329
330330 it 'should make connection attempts to sandbox.a.fallback.ably-realtime.com, sandbox.b.fallback.ably-realtime.com, sandbox.c.fallback.ably-realtime.com, sandbox.d.fallback.ably-realtime.com, sandbox.e.fallback.ably-realtime.com (#RSC15a)' do
331331 hosts = [ ]
@@ -338,7 +338,7 @@ def encode64(text)
338338 end
339339
340340 context 'when environment is production' do
341- let ( :custom_hosts ) { %w( a. ably-realtime.com b .ably-realtime.com) }
341+ let ( :custom_hosts ) { %w( main.a.fallback. ably-realtime.com main.b.fallback .ably-realtime.com) }
342342 let ( :max_retry_count ) { 2 }
343343 let ( :max_retry_duration ) { 0.5 }
344344 let ( :fallback_block ) { proc { raise Faraday ::SSLError . new ( 'ssl error message' ) } }
@@ -366,7 +366,7 @@ def encode64(text)
366366
367367 context 'and connection times out' do
368368 let! ( :default_host_request_stub ) do
369- stub_request ( :post , "https://#{ Ably :: Rest :: Client :: DOMAIN } #{ path } " ) . to_return do
369+ stub_request ( :post , "https://#{ client . hostname } #{ path } " ) . to_return do
370370 raise Faraday ::TimeoutError . new ( 'timeout error message' )
371371 end
372372 end
@@ -380,7 +380,7 @@ def encode64(text)
380380
381381 context "and the total request time exeeds #{ http_defaults . fetch ( :max_retry_duration ) } seconds" do
382382 let! ( :default_host_request_stub ) do
383- stub_request ( :post , "https://#{ Ably :: Rest :: Client :: DOMAIN } #{ path } " ) . to_return do
383+ stub_request ( :post , "https://#{ client . hostname } #{ path } " ) . to_return do
384384 sleep max_retry_duration * 1.5
385385 raise Faraday ::TimeoutError . new ( 'timeout error message' )
386386 end
@@ -397,7 +397,7 @@ def encode64(text)
397397
398398 context 'and connection fails' do
399399 let! ( :default_host_request_stub ) do
400- stub_request ( :post , "https://#{ Ably :: Rest :: Client :: DOMAIN } #{ path } " ) . to_return do
400+ stub_request ( :post , "https://#{ client . hostname } #{ path } " ) . to_return do
401401 raise Faraday ::ConnectionFailed . new ( 'connection failure error message' )
402402 end
403403 end
@@ -422,7 +422,7 @@ def encode64(text)
422422 end
423423 let ( :requests ) { [ ] }
424424 let! ( :default_host_request_stub ) do
425- stub_request ( :post , "https://#{ Ably :: Rest :: Client :: DOMAIN } #{ path } " ) . to_return do
425+ stub_request ( :post , "https://#{ client . hostname } #{ path } " ) . to_return do
426426 requests << true
427427 if requests . count == 1
428428 raise Faraday ::ConnectionFailed . new ( 'connection failure error message' )
@@ -450,7 +450,7 @@ def encode64(text)
450450 context 'and basic authentication fails' do
451451 let ( :status ) { 401 }
452452 let! ( :default_host_request_stub ) do
453- stub_request ( :post , "https://#{ Ably :: Rest :: Client :: DOMAIN } #{ path } " ) . to_return (
453+ stub_request ( :post , "https://#{ client . hostname } #{ path } " ) . to_return (
454454 headers : { 'Content-Type' => 'application/json' } ,
455455 status : status ,
456456 body : {
@@ -482,7 +482,7 @@ def encode64(text)
482482 end
483483 end
484484 let! ( :default_host_request_stub ) do
485- stub_request ( :post , "https://#{ Ably :: Rest :: Client :: DOMAIN } #{ path } " ) . to_return ( &fallback_block )
485+ stub_request ( :post , "https://#{ client . hostname } #{ path } " ) . to_return ( &fallback_block )
486486 end
487487
488488 it 'attempts the fallback hosts as this is an authentication failure (#RSC15d)' do
@@ -518,7 +518,7 @@ def encode64(text)
518518 end
519519 end
520520 let! ( :default_host_request_stub ) do
521- stub_request ( :post , "https://#{ Ably :: Rest :: Client :: DOMAIN } #{ path } " ) . to_return ( &fallback_block )
521+ stub_request ( :post , "https://#{ client . hostname } #{ path } " ) . to_return ( &fallback_block )
522522 end
523523
524524 context 'with custom fallback hosts provided' do
@@ -555,7 +555,7 @@ def encode64(text)
555555
556556 context 'using a local web-server' , webmock : false do
557557 let ( :primary_host ) { 'local.realtime.ably.net' }
558- let ( :fallbacks ) { [ 'local .ably.net' , 'localhost' ] }
558+ let ( :fallbacks ) { [ 'localhost .ably.net' , 'localhost' ] }
559559 let ( :port ) { rand ( 10000 ) + 2000 }
560560 let ( :channel_name ) { 'foo' }
561561 let ( :request_timeout ) { 3 }
@@ -863,7 +863,7 @@ def encode64(text)
863863 end
864864 end
865865 let! ( :default_host_request_stub ) do
866- stub_request ( :post , "https://#{ env } - #{ Ably :: Rest :: Client :: DOMAIN } #{ path } " ) . to_return ( &fallback_block )
866+ stub_request ( :post , "https://#{ client . hostname } #{ path } " ) . to_return ( &fallback_block )
867867 end
868868
869869 context 'with no fallback hosts provided (#TBC, see https://github.com/ably/wiki/issues/361)' do
@@ -1374,7 +1374,7 @@ def encode64(text)
13741374 let ( :client_options ) do
13751375 default_options . merge (
13761376 rest_host : 'non.existent.domain.local' ,
1377- fallback_hosts : [ [ environment , Ably :: Rest :: Client :: DOMAIN ] . join ( '-' ) ] ,
1377+ fallback_hosts : [ "sandbox.realtime.ably-nonprod.net" ] ,
13781378 key : api_key ,
13791379 logger : custom_logger ,
13801380 log_retries_as_info : false )
0 commit comments