Skip to content

Commit

Permalink
RTN14c (#421)
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardopereira authored and tcard committed Apr 29, 2016
1 parent 9bbb1f3 commit 743c1e1
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Spec/RealtimeClientConnection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1522,6 +1522,31 @@ class RealtimeClientConnection: QuickSpec {
expect(failures[0].error!.code).to(equal(40142))
}

// RTN14c
it("connection attempt should fail if not connected within the default realtime request timeout") {
let options = AblyTests.commonAppSetup()
options.realtimeHost = "10.255.255.1" //non-routable IP address
options.autoConnect = false
let previousRealtimeRequestTimeout = ARTDefault.realtimeRequestTimeout()
defer { ARTDefault.setRealtimeRequestTimeout(previousRealtimeRequestTimeout) }
ARTDefault.setRealtimeRequestTimeout(0.5)

let client = ARTRealtime(options: options)
defer { client.close() }
var start, end: NSDate?
waitUntil(timeout: testTimeout) { done in
client.connection.on(.Disconnected) { stateChange in
end = NSDate()
expect(stateChange!.reason!.message).to(contain("timed out"))
expect(client.connection.errorReason!).to(beIdenticalTo(stateChange!.reason))
done()
}
client.connect()
start = NSDate()
}
expect(end!.timeIntervalSinceDate(start!)).to(beCloseTo(ARTDefault.realtimeRequestTimeout(), within: 1.5))
}

// RTN14d
it("connection attempt fails for any recoverable reason") {
let options = AblyTests.commonAppSetup()
Expand Down

0 comments on commit 743c1e1

Please sign in to comment.