diff --git a/Spec/RealtimeClientConnection.swift b/Spec/RealtimeClientConnection.swift index 6ca4c6fba..7daa09af6 100644 --- a/Spec/RealtimeClientConnection.swift +++ b/Spec/RealtimeClientConnection.swift @@ -2489,6 +2489,46 @@ class RealtimeClientConnection: QuickSpec { expect(NSRegularExpression.match(urlConnections[0].absoluteString, pattern: "//realtime.ably.io")).to(beTrue()) } + // RTN17a + pending("every connection is first attempted to the primary host realtime.ably.io") { + let options = ARTClientOptions(key: "xxxx:xxxx") + options.autoConnect = false + let client = ARTRealtime(options: options) + let channel = client.channels.get("test") + + client.setTransportClass(TestProxyTransport.self) + TestProxyTransport.network = .HostUnreachable + defer { TestProxyTransport.network = nil } + + var urlConnections = [NSURL]() + TestProxyTransport.networkConnectEvent = { url in + urlConnections.append(url) + TestProxyTransport.network = nil + } + + client.connect() + defer { client.close() } + + waitUntil(timeout: testTimeout) { done in + channel.publish(nil, data: "message") { error in + done() + } + } + + client.connect() + + waitUntil(timeout: testTimeout) { done in + channel.publish(nil, data: "message") { error in + done() + } + } + + expect(urlConnections).to(haveCount(3)) + expect(NSRegularExpression.match(urlConnections[0].absoluteString, pattern: "//realtime.ably.io")).to(beTrue()) + expect(NSRegularExpression.match(urlConnections[1].absoluteString, pattern: "//[a-e].ably-realtime.com")).to(beTrue()) + expect(NSRegularExpression.match(urlConnections[2].absoluteString, pattern: "//realtime.ably.io")).to(beTrue()) + } + } // RTN18