Skip to content

Commit

Permalink
Merge pull request #146 from ably/fix-rsl1c
Browse files Browse the repository at this point in the history
RSL1c: check that it happens in a single request.
  • Loading branch information
mattheworiordan committed Jan 26, 2016
2 parents 909cce3 + 2dd6635 commit c678de0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion ablySpec/RestChannel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,11 @@ class RestChannel: QuickSpec {

// RSL1c
context("with an array of Message objects") {
it("publishes the messages and invokes callback with success") {
it("publishes the messages in a single request and invokes callback with success") {
let oldExecutor = client.httpExecutor
defer { client.httpExecutor = oldExecutor}
client.httpExecutor = mockExecutor

var publishError: NSError? = NSError(domain: "", code: -1, userInfo: nil)
var publishedMessages: [ARTMessage] = []

Expand All @@ -180,6 +184,7 @@ class RestChannel: QuickSpec {
]
channel.publishMessages(messages) { error in
publishError = error
client.httpExecutor = oldExecutor
try! channel.history(nil) { result, _ in
if let items = result?.items as? [ARTMessage] {
publishedMessages.appendContentsOf(items)
Expand All @@ -191,6 +196,8 @@ class RestChannel: QuickSpec {
expect(publishedMessages.count).toEventually(equal(messages.count), timeout: testTimeout)
expect(publishedMessages).toEventually(contain(messages.first), timeout: testTimeout)
expect(publishedMessages).toEventually(contain(messages.last), timeout: testTimeout)

expect(mockExecutor.requests.count).to(equal(1))
}
}
}
Expand Down

0 comments on commit c678de0

Please sign in to comment.