Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RTN14c #421

Merged
merged 5 commits into from
Apr 29, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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