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

RTL4b #187

Merged
merged 1 commit into from
Feb 8, 2016
Merged

RTL4b #187

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
57 changes: 57 additions & 0 deletions ablySpec/RealtimeClientChannel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,63 @@ class RealtimeClientChannel: QuickSpec {
// RTL4
describe("attach") {

// RTL4b
context("results in an error if the connection state is") {

pending("CLOSING") {
let options = AblyTests.commonAppSetup()
options.autoConnect = false
let client = ARTRealtime(options: options)
client.setTransportClass(TestProxyTransport.self)
client.connect()
defer { client.close() }

expect(client.connection().state).toEventually(equal(ARTRealtimeConnectionState.Connected), timeout: testTimeout)
let transport = client.transport as! TestProxyTransport
transport.actionsIgnored += [.Closed]

let channel = client.channel("test")

client.close()
expect(client.connection().state).to(equal(ARTRealtimeConnectionState.Closing))

expect(channel.attach()).toNot(beNil())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not clear that this is an error, this applies to all cases below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can I correct this after the API changes?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, please add a TODO or an issue though so we don't forget

}

it("CLOSED") {
let client = ARTRealtime(options: AblyTests.commonAppSetup())
defer { client.close() }

let channel = client.channel("test")

client.close()
expect(client.connection().state).toEventually(equal(ARTRealtimeConnectionState.Closed), timeout: testTimeout)

expect(channel.attach()).toNot(beNil())
}

it("SUSPENDED") {
let client = ARTRealtime(options: AblyTests.commonAppSetup())
defer { client.close() }

let channel = client.channel("test")
client.onSuspended()
expect(client.connection().state).to(equal(ARTRealtimeConnectionState.Suspended))
expect(channel.attach()).toNot(beNil())
}

it("FAILED") {
let client = ARTRealtime(options: AblyTests.commonAppSetup())
defer { client.close() }

let channel = client.channel("test")
client.onError(AblyTests.newErrorProtocolMessage())
expect(client.connection().state).to(equal(ARTRealtimeConnectionState.Failed))
expect(channel.attach()).toNot(beNil())
}

}

// RTL4c
it("should send an ATTACH ProtocolMessage, change state to ATTACHING and change state to ATTACHED after confirmation") {
let options = AblyTests.commonAppSetup()
Expand Down