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

RTP8d #326

Merged
merged 1 commit into from
Apr 5, 2016
Merged

RTP8d #326

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
45 changes: 45 additions & 0 deletions Spec/RealtimeClientPresence.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,51 @@ class RealtimeClientPresence: QuickSpec {
}
}

// RTP8
context("enter") {

// RTP8d
it("implicitly attaches the Channel") {
let options = AblyTests.commonAppSetup()
options.clientId = "john"

let client = ARTRealtime(options: options)
defer { client.close() }
let channel = client.channels.get("test")

expect(channel.state).to(equal(ARTRealtimeChannelState.Initialized))
waitUntil(timeout: testTimeout) { done in
channel.presence.enter("online") { error in
expect(error).to(beNil())
done()
}
expect(channel.state).to(equal(ARTRealtimeChannelState.Attaching))
}
expect(channel.state).to(equal(ARTRealtimeChannelState.Attached))
}

// RTP8d
it("should result in an error if the channel is in the FAILED state") {
let options = AblyTests.commonAppSetup()
options.clientId = "john"

let client = ARTRealtime(options: options)
defer { client.close() }
let channel = client.channels.get("test")

channel.onError(AblyTests.newErrorProtocolMessage())

waitUntil(timeout: testTimeout) { done in
channel.presence.enter("online") { error in
expect(error!.message).to(contain("invalid channel state"))
done()
}
}
expect(channel.state).to(equal(ARTRealtimeChannelState.Failed))
}

}

// RTP15e
let cases: [String:(ARTRealtimePresence, Optional<(ARTErrorInfo?)->Void>)->()] = [
"enterClient": { $0.enterClient("john", data: nil, callback: $1) },
Expand Down