Skip to content

Commit

Permalink
RTP8d
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardopereira committed Mar 21, 2016
1 parent 7b60ed5 commit 6ff1a27
Showing 1 changed file with 45 additions and 0 deletions.
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

0 comments on commit 6ff1a27

Please sign in to comment.