Skip to content

Commit

Permalink
Merge pull request #219 from ably/RTL8
Browse files Browse the repository at this point in the history
RTL8
  • Loading branch information
ricardopereira committed Feb 18, 2016
2 parents 0fed5ed + b909625 commit b849e8f
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions ablySpec/RealtimeClientChannel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,55 @@ class RealtimeClientChannel: QuickSpec {

}

// RTL8
context("unsubscribe") {

// RTL8a
it("with no arguments unsubscribes the provided listener to all messages if subscribed") {
let client = ARTRealtime(options: AblyTests.commonAppSetup())
defer { client.close() }

let channel = client.channels.get("test")

waitUntil(timeout: testTimeout) { done in
let listener = channel.subscribe { message in
fail("Listener shouldn't exist")
done()
}

channel.unsubscribe(listener)

channel.publish(nil, data: "message") { errorInfo in
expect(errorInfo).to(beNil())
done()
}
}
}

// RTL8b
it("with a single name argument unsubscribes the provided listener if previously subscribed with a name-specific subscription") {
let client = ARTRealtime(options: AblyTests.commonAppSetup())
defer { client.close() }

let channel = client.channels.get("test")

waitUntil(timeout: testTimeout) { done in
let eventAListener = channel.subscribe("eventA") { message in
fail("Listener shouldn't exist")
done()
}

channel.unsubscribe("eventA", listener: eventAListener)

channel.publish("eventA", data: "message") { errorInfo in
expect(errorInfo).to(beNil())
done()
}
}
}

}

// RTL10
context("history") {

Expand Down

0 comments on commit b849e8f

Please sign in to comment.